* NATIONAL PARTY ORGANIZATIONS AND PARTY BRANDS IN AMERICAN POLITICS: THE DNC AND RNC, 1912-2016
* Boris Heersink (contact at: bheersink@fordham.edu / www.borisheersink.com)

* Set-up
clear
set more off
*cd "[Adjust cd and delete * at start of this line]" 
set scheme s1mono
capture log close

* This do file includes all relevant code to replicate the analysis presented in "National Party Organizations and Party Brands in American Politics: The Democratic and Republican National Committees, 1912-2016" 
* The first section includes the code necessary to produce the relevant data sets, subsequently it includes code necessary to produce each of the figures and tables by chapter. 

* CREATE MAIN DATA SETS 

* Electoral Performance Data

use ElectoralPerformance.dta
label variable pvperc_d "Presidential Pop. Vote %"
label variable houseperc_d "House Seat %"
label variable senateperc_d "Senate Seat %"
label variable pvperc_r "Presidential Pop. Vote %"
label variable houseperc_r "House Seat %"
label variable senateperc_r "Senate Seat %"
save ElectoralPerformance.dta, replace

* Descriptive NYT Data

use DescriptiveData_1913_2016.dta
label variable dnctotal "DNC Total"
label variable rnctotal "RNC Total"
label variable dncrelevant "DNC Relevant"
label variable rncrelevant "RNC Relevant"
save DescriptiveData_1913_2016.dta, replace 

* NYT Data 1913-2016

use Data_1913_2016

*Drop Pre-Election November Articles
drop if (year==1916 & month==11 & presey==1) | (year==1920 & month==11 & presey==1) | (year==1924 & month==11 & presey==1) | (year==1928 & month==11 & presey==1) | ///
(year==1932 & month==11 & presey==1) | (year==1936 & month==11 & presey==1) | (year==1940 & month==11 & presey==1) | (year==1944 & month==11 & presey==1) | ///
(year==1948 & month==11 & presey==1) | (year==1952 & month==11 & presey==1) | (year==1956 & month==11 & presey==1) | (year==1960 & month==11 & presey==1) | ///
(year==1964 & month==11 & presey==1) | (year==1968 & month==11 & presey==1) | (year==1972 & month==11 & presey==1) | (year==1976 & month==11 & presey==1) | ///
(year==1980 & month==11 & presey==1) | (year==1984 & month==11 & presey==1) | (year==1988 & month==11 & presey==1) | (year==1992 & month==11 & presey==1) | ///
(year==1996 & month==11 & presey==1) | (year==2000 & month==12 & presey==1) | (year==2004 & month==11 & presey==1) | (year==2008 & month==11 & presey==1) | ///
(year==2012 & month==11 & presey==1) | (year==2016 & month==11 & presey==1)
drop if month==11 & midey==1

*Generate Majority Status variable
gen majority = 0
replace majority=1 if whitehouse==1 & house==1 & senate==1
gen congressmaj = 0
replace congressmaj=1 if house==1 & senate==1

*Generate CampaignTarget variable
gen campaigntarget = 0
replace campaigntarget=1 if target==1
replace campaigntarget=1 if campaign==1
replace campaigntarget=1 if mobil==1

*Generate Branding Activities variable
gen branding = 0
replace branding=1 if attack==1
replace branding=1 if pub==1
replace branding=1 if policy==1

*Generate Service Activities variable 
gen service = 0
replace service=1 if campaigntarget==1
replace service=1 if human==1
replace service=1 if recruit==1
replace service=1 if fund==1

*Generate Non-Branding Activities variable 
gen nonbranding = 0
replace nonbranding=1 if campaigntarget==1
replace nonbranding=1 if human==1
replace nonbranding=1 if recruit==1
replace nonbranding=1 if fund==1
replace nonbranding=1 if patronage==1
replace nonbranding=1 if convention==1

*Generate Other Activities variable
gen other = 0
replace other=1 if patronage==1
replace other=1 if generic==1
replace other=1 if convention==1

*Generate Sum of Activities variables 
gen brandingsum = 0
replace brandingsum = attack + pub + policy
gen nonbrandingsum = 0
replace nonbrandingsum = campaigntarget + human + recruit + fund + patronage + convention
gen servicesum = 0
replace servicesum = campaigntarget + human + recruit + fund
gen othersum = 0
replace othersum = patronage + generic + convention
gen allsum = 0
replace allsum = brandingsum + servicesum + othersum
gen nongeneric = 0
replace nongeneric = brandingsum + servicesum + patronage + convention
gen brandingservice = 0
replace brandingservice = brandingsum + servicesum

*Generate Minority President
gen minpres = 0
replace minpres = 1 if (majority==0 & whitehouse==1)

save Data_1913_2016_2.dta, replace

* Collapse Data by Month
collapse (sum) majority branding nonbranding service other brandingsum nonbrandingsum servicesum brandingservice othersum allsum attack pub ///
policy target campaign campaigntarget human recruit mobil fund patronage generic convention presey midey whitehouse house senate congressmaj /// 
minpres scandal wilson harding coolidge hoover roosevelt truman eisenhower kennedy johnson nixon ford carter reagan hwbush clinton wbush obama trump ///
mccombs mccormick cummings gwhite hull shaver raskob farley flynn walker hannegan mcgrath boyle mckinney mitchell pbutler jackson bailey obrien1 ///
harris obrien2 obrientot westwood strauss curtis jcwhite manatt kirk brown wilhelm delee dodd_fowler romer_gross rendell_andrew mcauliffe dean ///
kaine wasserman brazile hilles wilcox hays adams wmbutler work huston fess sanders fletcher hamilton martin spangler brownell reece scott gabrielson summerfield ///
roberts hall alcorn tbmorton miller burch bliss rmorton dole bush smith brock richards fahrenkopf atwater yeutter bond barbour nicholson gilmore racicot ///
gillespie mehlman martinez duncan steele priebus (mean) length, by(month year dem) 
replace majority = 1 if majority > 1 & majority != .
replace presey = 1 if presey > 1 & presey != .
replace midey = 1 if midey > 1 & midey != .
replace whitehouse = 1 if whitehouse > 1 & whitehouse != .
replace house = 1 if house > 1 & house != .
replace senate = 1 if senate > 1 & senate != .
replace congressmaj = 1 if congressmaj > 1 & congressmaj !=.
replace minpres = 1 if minpres > 1 & minpres !=.
replace wilson = 1 if wilson > 1 & wilson !=.
replace harding = 1 if harding > 1 & harding !=.
replace coolidge = 1 if coolidge > 1 & coolidge !=.
replace hoover = 1 if hoover > 1 & hoover !=.
replace roosevelt = 1 if roosevelt > 1 & roosevelt !=.
replace truman = 1 if truman > 1 & truman !=.
replace eisenhower = 1 if eisenhower > 1 & eisenhower !=.
replace kennedy = 1 if kennedy > 1 & kennedy !=.
replace johnson = 1 if johnson > 1 & johnson !=.
replace nixon = 1 if nixon > 1 & nixon !=.
replace ford = 1 if ford > 1 & ford !=.
replace carter = 1 if carter > 1 & carter !=.
replace reagan = 1 if reagan > 1 & reagan !=.
replace hwbush = 1 if hwbush > 1 & hwbush !=.
replace clinton = 1 if clinton > 1 & clinton !=.
replace wbush = 1 if wbush > 1 & wbush !=.
replace obama = 1 if obama > 1 & obama !=.
replace trump = 1 if trump > 1 & trump !=.
replace mccombs = 1 if mccombs > 1 & mccombs !=.
replace mccormick = 1 if mccormick > 1 & mccormick !=.
replace cummings = 1 if cummings > 1 & cummings !=.
replace gwhite = 1 if gwhite > 1 & gwhite !=.
replace hull = 1 if hull > 1 & hull !=.
replace shaver = 1 if shaver > 1 & shaver !=.
replace raskob = 1 if raskob > 1 & raskob !=.
replace farley = 1 if farley > 1 & farley !=.
replace flynn = 1 if flynn > 1 & flynn !=.
replace walker = 1 if walker > 1 & walker !=.
replace hannegan = 1 if hannegan > 1 & hannegan !=.
replace mcgrath = 1 if mcgrath > 1 & mcgrath !=.
replace boyle = 1 if boyle > 1 & boyle !=.
replace mckinney = 1 if mckinney > 1 & mckinney !=.
replace mitchell = 1 if mitchell > 1 & mitchell !=.
replace pbutler = 1 if pbutler > 1 & pbutler !=.
replace jackson = 1 if jackson > 1 & jackson !=.
replace bailey = 1 if bailey > 1 & bailey !=.
replace obrien1 = 1 if obrien1 > 1 & obrien1 !=.
replace harris = 1 if harris > 1 & harris !=.
replace obrien2 = 1 if obrien2 > 1 & obrien2 !=.
replace obrientot = 1 if obrientot > 1 & obrientot !=.
replace westwood = 1 if westwood > 1 & westwood !=.
replace strauss = 1 if strauss > 1 & strauss !=.
replace curtis = 1 if curtis > 1 & curtis !=.
replace jcwhite = 1 if jcwhite > 1 & jcwhite !=.
replace manatt = 1 if manatt > 1 & manatt !=.
replace kirk = 1 if kirk > 1 & kirk !=.
replace brown = 1 if brown > 1 & brown !=.
replace wilhelm = 1 if wilhelm > 1 & wilhelm !=.
replace delee = 1 if delee > 1 & delee !=.
replace dodd_fowler = 1 if dodd_fowler > 1 & dodd_fowler !=.
replace romer_gross = 1 if romer_gross > 1 & romer_gross !=.
replace rendell_andrew = 1 if rendell_andrew > 1 & rendell_andrew !=.
replace mcauliffe = 1 if mcauliffe > 1 & mcauliffe !=.
replace dean = 1 if dean > 1 & dean !=.
replace kaine = 1 if kaine > 1 & kaine !=.
replace wasserman = 1 if wasserman > 1 & wasserman !=.
replace brazile = 1 if brazile > 1 & brazile !=.
replace hilles = 1 if hilles > 1 & hilles !=.
replace wilcox = 1 if wilcox > 1 & wilcox !=.
replace hays = 1 if hays > 1 & hays !=.
replace adams = 1 if adams > 1 & adams !=.
replace wmbutler = 1 if wmbutler > 1 & wmbutler !=.
replace work = 1 if work > 1 & work !=.
replace huston = 1 if huston > 1 & huston !=.
replace fess = 1 if fess > 1 & fess !=.
replace sanders = 1 if sanders > 1 & sanders !=.
replace fletcher = 1 if fletcher > 1 & fletcher !=.
replace hamilton = 1 if hamilton > 1 & hamilton !=.
replace martin = 1 if martin > 1 & martin !=.
replace spangler = 1 if spangler > 1 & spangler !=.
replace brownell = 1 if brownell > 1 & brownell !=.
replace reece = 1 if reece > 1 & reece !=.
replace scott = 1 if scott > 1 & scott !=.
replace gabrielson = 1 if gabrielson > 1 & gabrielson !=.
replace summerfield = 1 if summerfield > 1 & summerfield !=.
replace roberts = 1 if roberts > 1 & roberts !=.
replace hall = 1 if hall > 1 & hall !=.
replace alcorn = 1 if alcorn > 1 & alcorn !=.
replace tbmorton = 1 if tbmorton > 1 & tbmorton !=.
replace miller = 1 if miller > 1 & miller !=.
replace burch = 1 if burch > 1 & burch !=.
replace bliss = 1 if bliss > 1 & bliss !=.
replace rmorton = 1 if rmorton > 1 & rmorton !=.
replace dole = 1 if dole > 1 & dole !=.
replace bush = 1 if bush > 1 & bush !=.
replace smith = 1 if smith > 1 & smith !=.
replace brock = 1 if brock > 1 & brock !=.
replace richards = 1 if richards > 1 & richards !=.
replace fahrenkopf = 1 if fahrenkopf > 1 & fahrenkopf !=.
replace atwater = 1 if atwater > 1 & atwater !=.
replace yeutter = 1 if yeutter > 1 & yeutter !=.
replace bond = 1 if bond > 1 & bond !=.
replace barbour = 1 if barbour > 1 & barbour !=.
replace nicholson = 1 if nicholson > 1 & nicholson !=.
replace gilmore = 1 if gilmore > 1 & gilmore !=.
replace racicot = 1 if racicot > 1 & racicot !=.
replace gillespie = 1 if gillespie > 1 & gillespie !=.
replace mehlman = 1 if mehlman > 1 & mehlman !=.
replace martinez = 1 if martinez > 1 & martinez !=.
replace duncan = 1 if duncan > 1 & duncan !=.
replace steele = 1 if steele > 1 & steele !=.
replace priebus = 1 if priebus > 1 & priebus !=.

gen modate = ym(year, month)
format modate %tm
egen id = group(dem), label
xtset id modate
gen lag_brandingsum = L.brandingsum
gen lag_allsum = L.allsum
gen lag_servicesum = L.servicesum
gen lag_attack = L.attack
gen lag_pub = L.pub
gen lag_policy = L.policy
gen lag_campaigntarget = L.campaigntarget
gen lag_human = L.human
gen lag_recruit = L.recruit
gen lag_fund = L.fund

label variable majority "Majority President" 
label variable presey "Presidential Election"
label variable midey "Midterm Election"
label variable whitehouse "White House"
label variable house "House Majority"
label variable senate "Senate Majority"
label variable congressmaj "Congressional Majority"
label variable dem "Democratic Party"
label variable length "NYT Length"
label variable scandal "Scandal"
label variable brandingsum "Branding"
label variable lag_brandingsum "Branding (lagged)"
label variable allsum "All Activities"
label variable lag_allsum "All Activities (lagged)"
label variable servicesum "Service"
label variable lag_servicesum "Service (lagged)"
label variable attack "Attack"
label variable lag_attack "Attack (lagged)"
label variable pub "Publicity"
label variable lag_pub "Publicity (lagged)"
label variable policy "Policy"
label variable lag_policy "Policy (lagged)"
label variable campaigntarget "Campaign"
label variable lag_campaigntarget "Campaign (lagged)"
label variable human "Human and Capital"
label variable lag_human "Human and Capital (lagged)"
label variable recruit "Recruitment"
label variable lag_recruit "Recruitment (lagged)"
label variable fund "Fundraising"
label variable lag_fund "Fundraising (lagged)"
label variable carter "Carter"

save Data_1913_2016_3.dta, replace

* CODE FOR TABLES AND FIGURES BY CHAPTER

* Chapter 2: Examining Democratic and Republican National Committee Party Branding Activity Quantitatively

* Figure 2.1 [Total articles, DNC-RNC full period]
use DescriptiveData_1913_2016
line dnctotal year, yscale(range (0 950)) ylabel(0 (300) 950) xlabel(1912(8)2016) xtitle("") lpattern (solid dash) legend( region(lcolor(white)))
graph save dnctotal, replace
line rnctotal year, yscale(range (0 950)) ylabel(0 (300) 950) xlabel(1912(8)2016) xtitle("") lpattern (solid dash) legend( region(lcolor(white)))
graph save rnctotal, replace
gr combine dnctotal.gph rnctotal.gph, col(1) iscale(1)
graph save Figure2_1, replace
graph export Figure2_1.png, replace 

* Figure 2.2 [Total vs Relevant for DNC and RNC]
use DescriptiveData_1913_2016
line dnctotal dncrelevant year, yscale(range (0 950)) ylabel(0 (500) 950) xlabel(1912(8)2016) xtitle("") lpattern (solid dash) legend( region(lcolor(white)))
graph save dncarticles, replace
line rnctotal rncrelevant year, yscale(range (0 950)) ylabel(0 (500) 950) xlabel(1912(8)2016) xtitle("") lpattern (solid dash) legend( region(lcolor(white)))
graph save rncarticles, replace
gr combine dncarticles.gph rncarticles.gph, col(1) iscale(1)
graph save Figure2_2, replace
graph export Figure2_2.png, replace 

* Table 2.1: Presidents and NYT Coverage of Branding Activity - Negative Binomial Regression
use Data_1913_2016_3.dta
xi: nbreg lag_brandingsum whitehouse presey midey dem length scandal, robust
xi: nbreg lag_brandingsum whitehouse dem scandal i.year i.month, robust
xi: nbreg lag_brandingsum majority minpres presey midey dem length scandal, robust
xi: nbreg lag_brandingsum majority minpres dem scandal i.year i.month, robust

*Figure 2.3: Presidents and NYT Coverage of Branding Activity - Linear Regression
use Data_1913_2016_3.dta
reg lag_brandingsum whitehouse presey midey dem length scandal, robust
coefplot, keep(lag_brandingsum whitehouse presey midey dem length scandal) xline (0) legend( region(lcolor(white)))
graph save Figure2_3, replace
graph export Figure2_3.png, replace 

* Table 2.2: Comparison All, Branding, Service (lagged)
use Data_1913_2016_3.dta
xi: nbreg lag_allsum whitehouse presey midey dem length scandal, robust
xi: nbreg lag_brandingsum whitehouse presey midey dem length scandal, robust
xi: nbreg lag_servicesum whitehouse presey midey dem length scandal, robust

* Figure 2.4: Attacks, Publicity Activities, Policy (lagged)
use Data_1913_2016_3.dta
xi: nbreg lag_attack whitehouse presey midey dem length scandal, robust
estimates store Attack
xi: nbreg lag_pub whitehouse presey midey dem length scandal, robust
estimates store Publicity
xi: nbreg lag_policy whitehouse presey midey dem length scandal, robust
estimates store Policy
coefplot Attack Publicity Policy, drop(_cons) xline(0) legend( region(lcolor(white)))
graph save Figure2_4, replace
graph export Figure2_4.png, replace 

* Figure 2.5: Campaign, H&CD, Recruitment, Fundraising (lagged)
use Data_1913_2016_3.dta
xi: nbreg lag_campaigntarget whitehouse presey midey dem length scandal, robust
estimates store Campaign
xi: nbreg lag_human whitehouse presey midey dem length scandal, robust
estimates store HR
xi: nbreg lag_recruit whitehouse presey midey dem length scandal, robust
estimates store Recruitment
xi: nbreg lag_fund whitehouse presey midey dem length scandal, robust
estimates store Fundraising
coefplot Campaign HR Recruitment Fundraising, drop(_cons) xline(0) legend( region(lcolor(white)))
graph save Figure2_5, replace
graph export Figure2_5.png, replace 

*Figure 2.6: Parties Interaction Branding
use Data_1913_2016_3.dta
xi: nbreg lag_brandingsum whitehouse##dem presey midey length scandal, robust
margins i.whitehouse#i.dem
marginsplot, x(whitehouse) 
marginsplot, recast(scatter) legend( region(lcolor(white)))
graph save Figure2_6_control, replace

xi: nbreg lag_brandingsum whitehouse##dem length scandal i.year i.month, robust
margins i.whitehouse#i.dem
marginsplot, x(whitehouse) 
marginsplot, recast(scatter) legend( region(lcolor(white)))
graph save Figure2_6_fe, replace

gr combine Figure2_6_control.gph Figure2_6_fe.gph
graph save Figure2_6, replace
graph export Figure2_6.png, replace 

*Figure 2.7: Parties Interaction Service
use Data_1913_2016_3.dta
xi: nbreg lag_servicesum whitehouse##dem presey midey length scandal, robust
margins i.whitehouse#i.dem
marginsplot, x(whitehouse) 
marginsplot, recast(scatter) legend( region(lcolor(white)))
graph save Figure2_7_control, replace

xi: nbreg lag_servicesum whitehouse##dem length scandal i.year i.month, robust
margins i.whitehouse#i.dem
marginsplot, x(whitehouse) 
marginsplot, recast(scatter) legend( region(lcolor(white)))
graph save Figure2_7_fe, replace

gr combine Figure2_7_control.gph Figure2_7_fe.gph
graph save Figure2_7, replace
graph export Figure2_7.png, replace 

* Table 2.3: Time Periods 1913-1952
use Data_1913_2016_3.dta
xi: nbreg lag_brandingsum whitehouse presey midey dem length scandal if inrange(year, 1913,1952), robust
xi: nbreg lag_brandingsum whitehouse dem scandal i.year i.month if inrange(year, 1913,1952), robust
xi: nbreg lag_servicesum whitehouse presey midey dem length scandal if inrange(year, 1913,1952), robust
xi: nbreg lag_servicesum whitehouse dem scandal i.year i.month if inrange(year, 1913,1952), robust

* Table 2.4: Time Periods, 1953-2016
use Data_1913_2016_3.dta
xi: nbreg lag_brandingsum whitehouse presey midey dem length scandal if inrange(year, 1953,2016), robust
xi: nbreg lag_brandingsum whitehouse dem scandal i.year i.month if inrange(year, 1953,2016), robust
xi: nbreg lag_servicesum whitehouse presey midey dem length scandal if inrange(year, 1953,2016), robust
xi: nbreg lag_servicesum whitehouse dem scandal i.year i.month if inrange(year, 1953,2016), robust

* Figure 2.8: Carter
use Data_1913_2016_3.dta
xi: nbreg lag_brandingsum carter presey midey length scandal if (inrange(year, 1973,1980) & dem==1), robust
coefplot, keep(lag_brandingsum carter presey midey dem length scandal) xline (0) legend( region(lcolor(white)))
estimates store Branding
xi: nbreg lag_servicesum carter presey midey length scandal if (inrange(year, 1973,1980) & dem==1), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure2_8_a, replace
xi: nbreg lag_attack carter presey midey length scandal if (inrange(year, 1973,1980) & dem==1), robust
estimates store Attack
xi: nbreg lag_pub carter presey midey length scandal if (inrange(year, 1973,1980) & dem==1), robust
estimates store Publicity
xi: nbreg lag_policy carter presey midey length scandal if (inrange(year, 1973,1980) & dem==1), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure2_8_b, replace
gr combine Figure2_8_a.gph Figure2_8_b.gph, iscale(1)
graph save Figure2_8, replace
graph export Figure2_8.png, replace 

* Appendix Chapter 2

*Table A-2.1: Main Model Deconstructed
use Data_1913_2016_3.dta
xi: nbreg lag_brandingsum whitehouse, robust
xi: nbreg lag_brandingsum whitehouse presey, robust
xi: nbreg lag_brandingsum whitehouse presey midey, robust
xi: nbreg lag_brandingsum whitehouse presey midey dem, robust
xi: nbreg lag_brandingsum whitehouse presey midey dem length, robust
xi: nbreg lag_brandingsum whitehouse presey midey dem length scandal, robust

*Table A_2.2: Poisson Regression Results Table 1
use Data_1913_2016_3.dta
poisson lag_brandingsum whitehouse presey midey dem length scandal, robust
poisson lag_brandingsum whitehouse dem scandal i.year i.month, robust
poisson lag_brandingsum majority  minpres presey midey dem length scandal, robust
poisson lag_brandingsum majority minpres dem scandal i.year i.month, robust

*Table A-2.4: Time Series Negative Binomial Results Table 1
use Data_1913_2016_3.dta
tsset dem modate, monthly
save Data_TimeSeries13_16.dta, replace
use Data_TimeSeries13_16.dta
xi: nbreg brandingsum whitehouse presey midey dem length scandal, robust
xi: nbreg brandingsum whitehouse dem scandal i.year i.month, robust
xi: nbreg brandingsum majority minpres presey midey dem length scandal, robust
xi: nbreg brandingsum majority minpres dem scandal i.year i.month, robust

*Figure A-2.1: Quarterly Model
use Data_1913_2016
gen quarter = 0
replace quarter=1 if month==1
replace quarter=1 if month==2
replace quarter=1 if month==3
replace quarter=2 if month==4
replace quarter=2 if month==5
replace quarter=2 if month==6
replace quarter=3 if month==7
replace quarter=3 if month==8
replace quarter=3 if month==9
replace quarter=4 if month==10
replace quarter=4 if month==11
replace quarter=4 if month==12

* Drop November / December election articles [except 2000 November]
drop if (month==11 & year==1914) | (month==11 & year==1916) | (month==11 & year==1918) | (month==11 & year==1920) | (month==11 & year==1922) | ///
(month==11 & year==1924) | (month==11 & year==1926) | (month==11 & year==1928) | (month==11 & year==1930) | (month==11 & year==1932) | (month==11 & year==1934) | ///
(month==11 & year==1936) | (month==11 & year==1938) | (month==11 & year==1940) | (month==11 & year==1942) | (month==11 & year==1944) | (month==11 & year==1946) | ///
(month==11 & year==1948) | (month==11 & year==1950) | (month==11 & year==1952) | (month==11 & year==1954) | (month==11 & year==1956) | (month==11 & year==1958) | ///
(month==11 & year==1960) | (month==11 & year==1962) | (month==11 & year==1964) | (month==11 & year==1966) | (month==11 & year==1968) | (month==11 & year==1970) | ///
(month==11 & year==1972) | (month==11 & year==1974) | (month==11 & year==1976) | (month==11 & year==1978) | (month==11 & year==1980) | (month==11 & year==1982) | ///
(month==11 & year==1984) | (month==11 & year==1986) | (month==11 & year==1988) | (month==11 & year==1990) | (month==11 & year==1992) | (month==11 & year==1994) | ///
(month==11 & year==1996) | (month==11 & year==1998) | (month==11 & year==2002) | (month==11 & year==2004) | (month==11 & year==2006) | (month==11 & year==2008) | ///
(month==11 & year==2010) | (month==11 & year==2012) | (month==11 & year==2014) | (month==11 & year==2016)

drop if (month==12 & year==1914) | (month==12 & year==1916) | (month==12 & year==1918) | (month==12 & year==1920) | (month==12 & year==1922) | ///
(month==12 & year==1924) | (month==12 & year==1926) | (month==12 & year==1928) | (month==12 & year==1930) | (month==12 & year==1932) | (month==12 & year==1934) | ///
(month==12 & year==1936) | (month==12 & year==1938) | (month==12 & year==1940) | (month==12 & year==1942) | (month==12 & year==1944) | (month==12 & year==1946) | ///
(month==12 & year==1948) | (month==12 & year==1950) | (month==12 & year==1952) | (month==12 & year==1954) | (month==12 & year==1956) | (month==12 & year==1958) | ///
(month==12 & year==1960) | (month==12 & year==1962) | (month==12 & year==1964) | (month==12 & year==1966) | (month==12 & year==1968) | (month==12 & year==1970) | ///
(month==12 & year==1972) | (month==12 & year==1974) | (month==12 & year==1976) | (month==12 & year==1978) | (month==12 & year==1980) | (month==12 & year==1982) | ///
(month==12 & year==1984) | (month==12 & year==1986) | (month==12 & year==1988) | (month==12 & year==1990) | (month==12 & year==1992) | (month==12 & year==1994) | ///
(month==12 & year==1996) | (month==12 & year==1998) | (month==12 & year==2000) | (month==12 & year==2002) | (month==12 & year==2004) | (month==12 & year==2006) | ///
(month==12 & year==2008) | (month==12 & year==2010) | (month==12 & year==2012) | (month==12 & year==2014) | (month==12 & year==2016)

*Generate Majority Status variable
gen majority = 0
replace majority=1 if whitehouse==1 & house==1 & senate==1
gen congressmaj = 0
replace congressmaj=1 if house==1 & senate==1

*Generate CampaignTarget variable
gen campaigntarget = 0
replace campaigntarget=1 if target==1
replace campaigntarget=1 if campaign==1
replace campaigntarget=1 if mobil==1

*Generate Branding Activities variable
gen branding = 0
replace branding=1 if attack==1
replace branding=1 if pub==1
replace branding=1 if policy==1

*Generate Service Activities variable 
gen service = 0
replace service=1 if campaigntarget==1
replace service=1 if human==1
replace service=1 if recruit==1
replace service=1 if fund==1

*Generate Non-Branding Activities variable 
gen nonbranding = 0
replace nonbranding=1 if campaigntarget==1
replace nonbranding=1 if human==1
replace nonbranding=1 if recruit==1
replace nonbranding=1 if fund==1
replace nonbranding=1 if patronage==1
replace nonbranding=1 if convention==1

*Generate Other Activities variable
gen other = 0
replace other=1 if patronage==1
replace other=1 if generic==1
replace other=1 if convention==1

*Generate Sum of Activities variables 
gen brandingsum = 0
replace brandingsum = attack + pub + policy
gen nonbrandingsum = 0
replace nonbrandingsum = campaigntarget + human + recruit + fund + patronage + convention
gen servicesum = 0
replace servicesum = campaigntarget + human + recruit + fund
gen othersum = 0
replace othersum = patronage + generic + convention
gen allsum = 0
replace allsum = brandingsum + servicesum + othersum
gen nongeneric = 0
replace nongeneric = brandingsum + servicesum + patronage + convention
gen brandingservice = 0
replace brandingservice = brandingsum + servicesum

*Generate Minority President
gen minpres = 0
replace minpres = 1 if (majority==0 & whitehouse==1)

*Collapse Data by Quarter
collapse (sum) majority branding nonbranding service other brandingsum nonbrandingsum servicesum brandingservice othersum allsum attack pub ///
policy target campaign campaigntarget human recruit mobil fund patronage generic convention presey midey whitehouse house senate congressmaj /// 
minpres scandal wilson harding coolidge hoover roosevelt truman eisenhower kennedy johnson nixon ford carter reagan hwbush clinton wbush obama trump ///
mccombs mccormick cummings gwhite hull shaver raskob farley flynn walker hannegan mcgrath boyle mckinney mitchell pbutler jackson bailey obrien1 ///
harris obrien2 obrientot westwood strauss curtis jcwhite manatt kirk brown wilhelm delee dodd_fowler romer_gross rendell_andrew mcauliffe dean ///
kaine wasserman brazile hilles wilcox hays adams wmbutler work huston fess sanders fletcher hamilton martin spangler brownell reece scott gabrielson summerfield ///
roberts hall alcorn tbmorton miller burch bliss rmorton dole bush smith brock richards fahrenkopf atwater yeutter bond barbour nicholson gilmore racicot ///
gillespie mehlman martinez duncan steele priebus (mean) length, by(quarter year dem) 
replace majority = 1 if majority > 1 & majority != .
replace presey = 1 if presey > 1 & presey != .
replace midey = 1 if midey > 1 & midey != .
replace whitehouse = 1 if whitehouse > 1 & whitehouse != .
replace house = 1 if house > 1 & house != .
replace senate = 1 if senate > 1 & senate != .
replace congressmaj = 1 if congressmaj > 1 & congressmaj !=.
replace minpres = 1 if minpres > 1 & minpres !=.
replace wilson = 1 if wilson > 1 & wilson !=.
replace harding = 1 if harding > 1 & harding !=.
replace coolidge = 1 if coolidge > 1 & coolidge !=.
replace hoover = 1 if hoover > 1 & hoover !=.
replace roosevelt = 1 if roosevelt > 1 & roosevelt !=.
replace truman = 1 if truman > 1 & truman !=.
replace eisenhower = 1 if eisenhower > 1 & eisenhower !=.
replace kennedy = 1 if kennedy > 1 & kennedy !=.
replace johnson = 1 if johnson > 1 & johnson !=.
replace nixon = 1 if nixon > 1 & nixon !=.
replace ford = 1 if ford > 1 & ford !=.
replace carter = 1 if carter > 1 & carter !=.
replace reagan = 1 if reagan > 1 & reagan !=.
replace hwbush = 1 if hwbush > 1 & hwbush !=.
replace clinton = 1 if clinton > 1 & clinton !=.
replace wbush = 1 if wbush > 1 & wbush !=.
replace obama = 1 if obama > 1 & obama !=.
replace trump = 1 if trump > 1 & trump !=.
replace mccombs = 1 if mccombs > 1 & mccombs !=.
replace mccormick = 1 if mccormick > 1 & mccormick !=.
replace cummings = 1 if cummings > 1 & cummings !=.
replace gwhite = 1 if gwhite > 1 & gwhite !=.
replace hull = 1 if hull > 1 & hull !=.
replace shaver = 1 if shaver > 1 & shaver !=.
replace raskob = 1 if raskob > 1 & raskob !=.
replace farley = 1 if farley > 1 & farley !=.
replace flynn = 1 if flynn > 1 & flynn !=.
replace walker = 1 if walker > 1 & walker !=.
replace hannegan = 1 if hannegan > 1 & hannegan !=.
replace mcgrath = 1 if mcgrath > 1 & mcgrath !=.
replace boyle = 1 if boyle > 1 & boyle !=.
replace mckinney = 1 if mckinney > 1 & mckinney !=.
replace mitchell = 1 if mitchell > 1 & mitchell !=.
replace pbutler = 1 if pbutler > 1 & pbutler !=.
replace jackson = 1 if jackson > 1 & jackson !=.
replace bailey = 1 if bailey > 1 & bailey !=.
replace obrien1 = 1 if obrien1 > 1 & obrien1 !=.
replace harris = 1 if harris > 1 & harris !=.
replace obrien2 = 1 if obrien2 > 1 & obrien2 !=.
replace obrientot = 1 if obrientot > 1 & obrientot !=.
replace westwood = 1 if westwood > 1 & westwood !=.
replace strauss = 1 if strauss > 1 & strauss !=.
replace curtis = 1 if curtis > 1 & curtis !=.
replace jcwhite = 1 if jcwhite > 1 & jcwhite !=.
replace manatt = 1 if manatt > 1 & manatt !=.
replace kirk = 1 if kirk > 1 & kirk !=.
replace brown = 1 if brown > 1 & brown !=.
replace wilhelm = 1 if wilhelm > 1 & wilhelm !=.
replace delee = 1 if delee > 1 & delee !=.
replace dodd_fowler = 1 if dodd_fowler > 1 & dodd_fowler !=.
replace romer_gross = 1 if romer_gross > 1 & romer_gross !=.
replace rendell_andrew = 1 if rendell_andrew > 1 & rendell_andrew !=.
replace mcauliffe = 1 if mcauliffe > 1 & mcauliffe !=.
replace dean = 1 if dean > 1 & dean !=.
replace kaine = 1 if kaine > 1 & kaine !=.
replace wasserman = 1 if wasserman > 1 & wasserman !=.
replace brazile = 1 if brazile > 1 & brazile !=.
replace hilles = 1 if hilles > 1 & hilles !=.
replace wilcox = 1 if wilcox > 1 & wilcox !=.
replace hays = 1 if hays > 1 & hays !=.
replace adams = 1 if adams > 1 & adams !=.
replace wmbutler = 1 if wmbutler > 1 & wmbutler !=.
replace work = 1 if work > 1 & work !=.
replace huston = 1 if huston > 1 & huston !=.
replace fess = 1 if fess > 1 & fess !=.
replace sanders = 1 if sanders > 1 & sanders !=.
replace fletcher = 1 if fletcher > 1 & fletcher !=.
replace hamilton = 1 if hamilton > 1 & hamilton !=.
replace martin = 1 if martin > 1 & martin !=.
replace spangler = 1 if spangler > 1 & spangler !=.
replace brownell = 1 if brownell > 1 & brownell !=.
replace reece = 1 if reece > 1 & reece !=.
replace scott = 1 if scott > 1 & scott !=.
replace gabrielson = 1 if gabrielson > 1 & gabrielson !=.
replace summerfield = 1 if summerfield > 1 & summerfield !=.
replace roberts = 1 if roberts > 1 & roberts !=.
replace hall = 1 if hall > 1 & hall !=.
replace alcorn = 1 if alcorn > 1 & alcorn !=.
replace tbmorton = 1 if tbmorton > 1 & tbmorton !=.
replace miller = 1 if miller > 1 & miller !=.
replace burch = 1 if burch > 1 & burch !=.
replace bliss = 1 if bliss > 1 & bliss !=.
replace rmorton = 1 if rmorton > 1 & rmorton !=.
replace dole = 1 if dole > 1 & dole !=.
replace bush = 1 if bush > 1 & bush !=.
replace smith = 1 if smith > 1 & smith !=.
replace brock = 1 if brock > 1 & brock !=.
replace richards = 1 if richards > 1 & richards !=.
replace fahrenkopf = 1 if fahrenkopf > 1 & fahrenkopf !=.
replace atwater = 1 if atwater > 1 & atwater !=.
replace yeutter = 1 if yeutter > 1 & yeutter !=.
replace bond = 1 if bond > 1 & bond !=.
replace barbour = 1 if barbour > 1 & barbour !=.
replace nicholson = 1 if nicholson > 1 & nicholson !=.
replace gilmore = 1 if gilmore > 1 & gilmore !=.
replace racicot = 1 if racicot > 1 & racicot !=.
replace gillespie = 1 if gillespie > 1 & gillespie !=.
replace mehlman = 1 if mehlman > 1 & mehlman !=.
replace martinez = 1 if martinez > 1 & martinez !=.
replace duncan = 1 if duncan > 1 & duncan !=.
replace steele = 1 if steele > 1 & steele !=.
replace priebus = 1 if priebus > 1 & priebus !=.

gen modateq = yq(year, quarter)
format modateq %tq
egen id = group(dem), label
xtset id modateq

label variable majority "Majority President" 
label variable minpres "Minority President" 
label variable presey "Presidential Election"
label variable midey "Midterm Election"
label variable whitehouse "White House"
label variable house "House Majority"
label variable senate "Senate Majority"
label variable congressmaj "Congressional Majority"
label variable dem "Democratic Party"
label variable length "NYT Length"
label variable scandal "Scandal"
label variable brandingsum "Branding"

save Data_1913_2016_quarter.dta, replace

use Data_1913_2016_quarter.dta
xi: nbreg brandingsum whitehouse presey midey dem length scandal, robust
coefplot, keep(brandingsum whitehouse presey midey dem length scandal) xline (0) title("Control Variables") 
graph save quarter1, replace
xi: nbreg brandingsum whitehouse dem scandal i.year i.quarter, robust
coefplot, keep(brandingsum whitehouse dem scandal) xline (0) title("Fixed Effects")
graph save quarter2, replace
xi: nbreg brandingsum majority  minpres presey midey dem length scandal, robust
coefplot, keep(brandingsum majority minpres presey midey dem length scandal) xline (0)
graph save quarter3, replace
xi: nbreg brandingsum majority minpres dem scandal i.year i.quarter, robust
coefplot, keep(brandingsum majority minpres dem scandal) xline (0)
graph save quarter4, replace
gr combine quarter1.gph quarter2.gph quarter3.gph quarter4.gph, col(2) iscale(1)
graph save FigureA_2_1.gph, replace
graph export FigureA_2_1.png, replace 


*Figure A-2.2: Annual Model
use Data_1913_2016

* Drop November / December election articles [except 2000 November]
drop if (month==11 & year==1914) | (month==11 & year==1916) | (month==11 & year==1918) | (month==11 & year==1920) | (month==11 & year==1922) | ///
(month==11 & year==1924) | (month==11 & year==1926) | (month==11 & year==1928) | (month==11 & year==1930) | (month==11 & year==1932) | (month==11 & year==1934) | ///
(month==11 & year==1936) | (month==11 & year==1938) | (month==11 & year==1940) | (month==11 & year==1942) | (month==11 & year==1944) | (month==11 & year==1946) | ///
(month==11 & year==1948) | (month==11 & year==1950) | (month==11 & year==1952) | (month==11 & year==1954) | (month==11 & year==1956) | (month==11 & year==1958) | ///
(month==11 & year==1960) | (month==11 & year==1962) | (month==11 & year==1964) | (month==11 & year==1966) | (month==11 & year==1968) | (month==11 & year==1970) | ///
(month==11 & year==1972) | (month==11 & year==1974) | (month==11 & year==1976) | (month==11 & year==1978) | (month==11 & year==1980) | (month==11 & year==1982) | ///
(month==11 & year==1984) | (month==11 & year==1986) | (month==11 & year==1988) | (month==11 & year==1990) | (month==11 & year==1992) | (month==11 & year==1994) | ///
(month==11 & year==1996) | (month==11 & year==1998) | (month==11 & year==2002) | (month==11 & year==2004) | (month==11 & year==2006) | (month==11 & year==2008) | ///
(month==11 & year==2010) | (month==11 & year==2012) | (month==11 & year==2014) | (month==11 & year==2016)

drop if (month==12 & year==1914) | (month==12 & year==1916) | (month==12 & year==1918) | (month==12 & year==1920) | (month==12 & year==1922) | ///
(month==12 & year==1924) | (month==12 & year==1926) | (month==12 & year==1928) | (month==12 & year==1930) | (month==12 & year==1932) | (month==12 & year==1934) | ///
(month==12 & year==1936) | (month==12 & year==1938) | (month==12 & year==1940) | (month==12 & year==1942) | (month==12 & year==1944) | (month==12 & year==1946) | ///
(month==12 & year==1948) | (month==12 & year==1950) | (month==12 & year==1952) | (month==12 & year==1954) | (month==12 & year==1956) | (month==12 & year==1958) | ///
(month==12 & year==1960) | (month==12 & year==1962) | (month==12 & year==1964) | (month==12 & year==1966) | (month==12 & year==1968) | (month==12 & year==1970) | ///
(month==12 & year==1972) | (month==12 & year==1974) | (month==12 & year==1976) | (month==12 & year==1978) | (month==12 & year==1980) | (month==12 & year==1982) | ///
(month==12 & year==1984) | (month==12 & year==1986) | (month==12 & year==1988) | (month==12 & year==1990) | (month==12 & year==1992) | (month==12 & year==1994) | ///
(month==12 & year==1996) | (month==12 & year==1998) | (month==12 & year==2000) | (month==12 & year==2002) | (month==12 & year==2004) | (month==12 & year==2006) | ///
(month==12 & year==2008) | (month==12 & year==2010) | (month==12 & year==2012) | (month==12 & year==2014) | (month==12 & year==2016)

*Generate Majority Status variable
gen majority = 0
replace majority=1 if whitehouse==1 & house==1 & senate==1
gen congressmaj = 0
replace congressmaj=1 if house==1 & senate==1

*Generate CampaignTarget variable
gen campaigntarget = 0
replace campaigntarget=1 if target==1
replace campaigntarget=1 if campaign==1
replace campaigntarget=1 if mobil==1

*Generate Branding Activities variable
gen branding = 0
replace branding=1 if attack==1
replace branding=1 if pub==1
replace branding=1 if policy==1

*Generate Service Activities variable 
gen service = 0
replace service=1 if campaigntarget==1
replace service=1 if human==1
replace service=1 if recruit==1
replace service=1 if fund==1

*Generate Non-Branding Activities variable 
gen nonbranding = 0
replace nonbranding=1 if campaigntarget==1
replace nonbranding=1 if human==1
replace nonbranding=1 if recruit==1
replace nonbranding=1 if fund==1
replace nonbranding=1 if patronage==1
replace nonbranding=1 if convention==1

*Generate Other Activities variable
gen other = 0
replace other=1 if patronage==1
replace other=1 if generic==1
replace other=1 if convention==1

*Generate Sum of Activities variables 
gen brandingsum = 0
replace brandingsum = attack + pub + policy
gen nonbrandingsum = 0
replace nonbrandingsum = campaigntarget + human + recruit + fund + patronage + convention
gen servicesum = 0
replace servicesum = campaigntarget + human + recruit + fund
gen othersum = 0
replace othersum = patronage + generic + convention
gen allsum = 0
replace allsum = brandingsum + servicesum + othersum
gen nongeneric = 0
replace nongeneric = brandingsum + servicesum + patronage + convention
gen brandingservice = 0
replace brandingservice = brandingsum + servicesum

*Generate Minority President
gen minpres = 0
replace minpres = 1 if (majority==0 & whitehouse==1)

*Collapse data by year

collapse (sum) majority branding nonbranding service other brandingsum nonbrandingsum servicesum brandingservice othersum allsum attack pub ///
policy target campaign campaigntarget human recruit mobil fund patronage generic convention presey midey whitehouse house senate congressmaj /// 
minpres scandal wilson harding coolidge hoover roosevelt truman eisenhower kennedy johnson nixon ford carter reagan hwbush clinton wbush obama trump ///
mccombs mccormick cummings gwhite hull shaver raskob farley flynn walker hannegan mcgrath boyle mckinney mitchell pbutler jackson bailey obrien1 ///
harris obrien2 obrientot westwood strauss curtis jcwhite manatt kirk brown wilhelm delee dodd_fowler romer_gross rendell_andrew mcauliffe dean ///
kaine wasserman brazile hilles wilcox hays adams wmbutler work huston fess sanders fletcher hamilton martin spangler brownell reece scott gabrielson summerfield ///
roberts hall alcorn tbmorton miller burch bliss rmorton dole bush smith brock richards fahrenkopf atwater yeutter bond barbour nicholson gilmore racicot ///
gillespie mehlman martinez duncan steele priebus (mean) length, by(year dem) 
replace majority = 1 if majority > 1 & majority != .
replace presey = 1 if presey > 1 & presey != .
replace midey = 1 if midey > 1 & midey != .
replace whitehouse = 1 if whitehouse > 1 & whitehouse != .
replace house = 1 if house > 1 & house != .
replace senate = 1 if senate > 1 & senate != .
replace congressmaj = 1 if congressmaj > 1 & congressmaj !=.
replace minpres = 1 if minpres > 1 & minpres !=.
replace wilson = 1 if wilson > 1 & wilson !=.
replace harding = 1 if harding > 1 & harding !=.
replace coolidge = 1 if coolidge > 1 & coolidge !=.
replace hoover = 1 if hoover > 1 & hoover !=.
replace roosevelt = 1 if roosevelt > 1 & roosevelt !=.
replace truman = 1 if truman > 1 & truman !=.
replace eisenhower = 1 if eisenhower > 1 & eisenhower !=.
replace kennedy = 1 if kennedy > 1 & kennedy !=.
replace johnson = 1 if johnson > 1 & johnson !=.
replace nixon = 1 if nixon > 1 & nixon !=.
replace ford = 1 if ford > 1 & ford !=.
replace carter = 1 if carter > 1 & carter !=.
replace reagan = 1 if reagan > 1 & reagan !=.
replace hwbush = 1 if hwbush > 1 & hwbush !=.
replace clinton = 1 if clinton > 1 & clinton !=.
replace wbush = 1 if wbush > 1 & wbush !=.
replace obama = 1 if obama > 1 & obama !=.
replace trump = 1 if trump > 1 & trump !=.
replace mccombs = 1 if mccombs > 1 & mccombs !=.
replace mccormick = 1 if mccormick > 1 & mccormick !=.
replace cummings = 1 if cummings > 1 & cummings !=.
replace gwhite = 1 if gwhite > 1 & gwhite !=.
replace hull = 1 if hull > 1 & hull !=.
replace shaver = 1 if shaver > 1 & shaver !=.
replace raskob = 1 if raskob > 1 & raskob !=.
replace farley = 1 if farley > 1 & farley !=.
replace flynn = 1 if flynn > 1 & flynn !=.
replace walker = 1 if walker > 1 & walker !=.
replace hannegan = 1 if hannegan > 1 & hannegan !=.
replace mcgrath = 1 if mcgrath > 1 & mcgrath !=.
replace boyle = 1 if boyle > 1 & boyle !=.
replace mckinney = 1 if mckinney > 1 & mckinney !=.
replace mitchell = 1 if mitchell > 1 & mitchell !=.
replace pbutler = 1 if pbutler > 1 & pbutler !=.
replace jackson = 1 if jackson > 1 & jackson !=.
replace bailey = 1 if bailey > 1 & bailey !=.
replace obrien1 = 1 if obrien1 > 1 & obrien1 !=.
replace harris = 1 if harris > 1 & harris !=.
replace obrien2 = 1 if obrien2 > 1 & obrien2 !=.
replace obrientot = 1 if obrientot > 1 & obrientot !=.
replace westwood = 1 if westwood > 1 & westwood !=.
replace strauss = 1 if strauss > 1 & strauss !=.
replace curtis = 1 if curtis > 1 & curtis !=.
replace jcwhite = 1 if jcwhite > 1 & jcwhite !=.
replace manatt = 1 if manatt > 1 & manatt !=.
replace kirk = 1 if kirk > 1 & kirk !=.
replace brown = 1 if brown > 1 & brown !=.
replace wilhelm = 1 if wilhelm > 1 & wilhelm !=.
replace delee = 1 if delee > 1 & delee !=.
replace dodd_fowler = 1 if dodd_fowler > 1 & dodd_fowler !=.
replace romer_gross = 1 if romer_gross > 1 & romer_gross !=.
replace rendell_andrew = 1 if rendell_andrew > 1 & rendell_andrew !=.
replace mcauliffe = 1 if mcauliffe > 1 & mcauliffe !=.
replace dean = 1 if dean > 1 & dean !=.
replace kaine = 1 if kaine > 1 & kaine !=.
replace wasserman = 1 if wasserman > 1 & wasserman !=.
replace brazile = 1 if brazile > 1 & brazile !=.
replace hilles = 1 if hilles > 1 & hilles !=.
replace wilcox = 1 if wilcox > 1 & wilcox !=.
replace hays = 1 if hays > 1 & hays !=.
replace adams = 1 if adams > 1 & adams !=.
replace wmbutler = 1 if wmbutler > 1 & wmbutler !=.
replace work = 1 if work > 1 & work !=.
replace huston = 1 if huston > 1 & huston !=.
replace fess = 1 if fess > 1 & fess !=.
replace sanders = 1 if sanders > 1 & sanders !=.
replace fletcher = 1 if fletcher > 1 & fletcher !=.
replace hamilton = 1 if hamilton > 1 & hamilton !=.
replace martin = 1 if martin > 1 & martin !=.
replace spangler = 1 if spangler > 1 & spangler !=.
replace brownell = 1 if brownell > 1 & brownell !=.
replace reece = 1 if reece > 1 & reece !=.
replace scott = 1 if scott > 1 & scott !=.
replace gabrielson = 1 if gabrielson > 1 & gabrielson !=.
replace summerfield = 1 if summerfield > 1 & summerfield !=.
replace roberts = 1 if roberts > 1 & roberts !=.
replace hall = 1 if hall > 1 & hall !=.
replace alcorn = 1 if alcorn > 1 & alcorn !=.
replace tbmorton = 1 if tbmorton > 1 & tbmorton !=.
replace miller = 1 if miller > 1 & miller !=.
replace burch = 1 if burch > 1 & burch !=.
replace bliss = 1 if bliss > 1 & bliss !=.
replace rmorton = 1 if rmorton > 1 & rmorton !=.
replace dole = 1 if dole > 1 & dole !=.
replace bush = 1 if bush > 1 & bush !=.
replace smith = 1 if smith > 1 & smith !=.
replace brock = 1 if brock > 1 & brock !=.
replace richards = 1 if richards > 1 & richards !=.
replace fahrenkopf = 1 if fahrenkopf > 1 & fahrenkopf !=.
replace atwater = 1 if atwater > 1 & atwater !=.
replace yeutter = 1 if yeutter > 1 & yeutter !=.
replace bond = 1 if bond > 1 & bond !=.
replace barbour = 1 if barbour > 1 & barbour !=.
replace nicholson = 1 if nicholson > 1 & nicholson !=.
replace gilmore = 1 if gilmore > 1 & gilmore !=.
replace racicot = 1 if racicot > 1 & racicot !=.
replace gillespie = 1 if gillespie > 1 & gillespie !=.
replace mehlman = 1 if mehlman > 1 & mehlman !=.
replace martinez = 1 if martinez > 1 & martinez !=.
replace duncan = 1 if duncan > 1 & duncan !=.
replace steele = 1 if steele > 1 & steele !=.
replace priebus = 1 if priebus > 1 & priebus !=.

gen decade = .
replace decade=30 if (year==1913) | (year==1914) | (year==1915) | (year==1916) | (year==1917) | (year==1918) | (year==1919)
replace decade=20 if (year==1920) | (year==1921) | (year==1922) | (year==1923) | (year==1924) | (year==1925) | (year==1926) | (year==1927) | (year==1928) | (year==1929)
replace decade=30 if (year==1930) | (year==1931) | (year==1932) | (year==1933) | (year==1934) | (year==1935) | (year==1936) | (year==1937) | (year==1938) | (year==1939)
replace decade=40 if (year==1940) | (year==1941) | (year==1942) | (year==1943) | (year==1944) | (year==1945) | (year==1946) | (year==1947) | (year==1948) | (year==1949)
replace decade=50 if (year==1950) | (year==1951) | (year==1952) | (year==1953) | (year==1954) | (year==1955) | (year==1956) | (year==1957) | (year==1958) | (year==1959)
replace decade=60 if (year==1960) | (year==1961) | (year==1962) | (year==1963) | (year==1964) | (year==1965) | (year==1966) | (year==1967) | (year==1968) | (year==1969)
replace decade=70 if (year==1970) | (year==1971) | (year==1972) | (year==1973) | (year==1974) | (year==1975) | (year==1976) | (year==1977) | (year==1978) | (year==1979)
replace decade=80 if (year==1980) | (year==1981) | (year==1982) | (year==1983) | (year==1984) | (year==1985) | (year==1986) | (year==1987) | (year==1988) | (year==1989)
replace decade=90 if (year==1990) | (year==1991) | (year==1992) | (year==1993) | (year==1994) | (year==1995) | (year==1996) | (year==1997) | (year==1998) | (year==1999)
replace decade=2000 if (year==2000) | (year==2001) | (year==2002) | (year==2003) | (year==2004) | (year==2005) | (year==2006) | (year==2007) | (year==2008) | (year==2009)
replace decade=2010 if (year==2010) | (year==2011) | (year==2012) | (year==2013) | (year==2014) | (year==2015) | (year==2016)

label variable majority "Majority President" 
label variable minpres "Minority President" 
label variable presey "Presidential Election"
label variable midey "Midterm Election"
label variable whitehouse "White House"
label variable house "House Majority"
label variable senate "Senate Majority"
label variable congressmaj "Congressional Majority"
label variable dem "Democratic Party"
label variable length "NYT Length"
label variable scandal "Scandal"
label variable brandingsum "Branding"

save Data_1913_2016_Year.dta, replace

use Data_1913_2016_Year.dta
xi: nbreg brandingsum whitehouse presey midey dem length scandal, robust
coefplot, keep(brandingsum whitehouse presey midey dem length scandal) xline (0) title("Control Variables")
graph save year1, replace
xi: nbreg brandingsum whitehouse dem scandal i.year, robust
coefplot, keep(brandingsum whitehouse dem scandal) xline (0) title("Fixed Effects")
graph save year2, replace
xi: nbreg brandingsum majority  minpres presey midey dem length scandal, robust
coefplot, keep(brandingsum majority minpres presey midey dem length scandal) xline (0)
graph save year3, replace
xi: nbreg brandingsum majority minpres dem scandal i.year, robust
coefplot, keep(brandingsum majority minpres dem scandal) xline (0)
graph save year4, replace
gr combine year1.gph year2.gph year3.gph year4.gph, col(2) iscale(1)
graph save FigureA_2_2.gph, replace
graph export FigureA_2_2.png, replace 


*Figure A_2.3: Congressional Term Model

use Data_1913_2016

* Drop November / December election articles [except 2000 November]
drop if (month==11 & year==1914) | (month==11 & year==1916) | (month==11 & year==1918) | (month==11 & year==1920) | (month==11 & year==1922) | ///
(month==11 & year==1924) | (month==11 & year==1926) | (month==11 & year==1928) | (month==11 & year==1930) | (month==11 & year==1932) | (month==11 & year==1934) | ///
(month==11 & year==1936) | (month==11 & year==1938) | (month==11 & year==1940) | (month==11 & year==1942) | (month==11 & year==1944) | (month==11 & year==1946) | ///
(month==11 & year==1948) | (month==11 & year==1950) | (month==11 & year==1952) | (month==11 & year==1954) | (month==11 & year==1956) | (month==11 & year==1958) | ///
(month==11 & year==1960) | (month==11 & year==1962) | (month==11 & year==1964) | (month==11 & year==1966) | (month==11 & year==1968) | (month==11 & year==1970) | ///
(month==11 & year==1972) | (month==11 & year==1974) | (month==11 & year==1976) | (month==11 & year==1978) | (month==11 & year==1980) | (month==11 & year==1982) | ///
(month==11 & year==1984) | (month==11 & year==1986) | (month==11 & year==1988) | (month==11 & year==1990) | (month==11 & year==1992) | (month==11 & year==1994) | ///
(month==11 & year==1996) | (month==11 & year==1998) | (month==11 & year==2002) | (month==11 & year==2004) | (month==11 & year==2006) | (month==11 & year==2008) | ///
(month==11 & year==2010) | (month==11 & year==2012) | (month==11 & year==2014) | (month==11 & year==2016)

drop if (month==12 & year==1914) | (month==12 & year==1916) | (month==12 & year==1918) | (month==12 & year==1920) | (month==12 & year==1922) | ///
(month==12 & year==1924) | (month==12 & year==1926) | (month==12 & year==1928) | (month==12 & year==1930) | (month==12 & year==1932) | (month==12 & year==1934) | ///
(month==12 & year==1936) | (month==12 & year==1938) | (month==12 & year==1940) | (month==12 & year==1942) | (month==12 & year==1944) | (month==12 & year==1946) | ///
(month==12 & year==1948) | (month==12 & year==1950) | (month==12 & year==1952) | (month==12 & year==1954) | (month==12 & year==1956) | (month==12 & year==1958) | ///
(month==12 & year==1960) | (month==12 & year==1962) | (month==12 & year==1964) | (month==12 & year==1966) | (month==12 & year==1968) | (month==12 & year==1970) | ///
(month==12 & year==1972) | (month==12 & year==1974) | (month==12 & year==1976) | (month==12 & year==1978) | (month==12 & year==1980) | (month==12 & year==1982) | ///
(month==12 & year==1984) | (month==12 & year==1986) | (month==12 & year==1988) | (month==12 & year==1990) | (month==12 & year==1992) | (month==12 & year==1994) | ///
(month==12 & year==1996) | (month==12 & year==1998) | (month==12 & year==2000) | (month==12 & year==2002) | (month==12 & year==2004) | (month==12 & year==2006) | ///
(month==12 & year==2008) | (month==12 & year==2010) | (month==12 & year==2012) | (month==12 & year==2014) | (month==12 & year==2016)

gen CongTerm = .
replace CongTerm=63 if (year==1913) | (year==1914)
replace CongTerm=64 if (year==1915) | (year==1916)
replace CongTerm=65 if (year==1917) | (year==1918)
replace CongTerm=66 if (year==1919) | (year==1920)
replace CongTerm=67 if (year==1921) | (year==1922)
replace CongTerm=68 if (year==1923) | (year==1924)
replace CongTerm=69 if (year==1925) | (year==1926)
replace CongTerm=70 if (year==1927) | (year==1928)
replace CongTerm=71 if (year==1929) | (year==1930)
replace CongTerm=72 if (year==1931) | (year==1932)
replace CongTerm=73 if (year==1933) | (year==1934)
replace CongTerm=74 if (year==1935) | (year==1936)
replace CongTerm=75 if (year==1937) | (year==1938)
replace CongTerm=76 if (year==1939) | (year==1940)
replace CongTerm=77 if (year==1941) | (year==1942)
replace CongTerm=78 if (year==1943) | (year==1944)
replace CongTerm=79 if (year==1945) | (year==1946)
replace CongTerm=80 if (year==1947) | (year==1948)
replace CongTerm=81 if (year==1949) | (year==1950)
replace CongTerm=82 if (year==1951) | (year==1952)
replace CongTerm=83 if (year==1953) | (year==1954)
replace CongTerm=84 if (year==1955) | (year==1956)
replace CongTerm=85 if (year==1957) | (year==1958)
replace CongTerm=86 if (year==1959) | (year==1960)
replace CongTerm=87 if (year==1961) | (year==1962)
replace CongTerm=88 if (year==1963) | (year==1964)
replace CongTerm=89 if (year==1965) | (year==1966)
replace CongTerm=90 if (year==1967) | (year==1968)
replace CongTerm=91 if (year==1969) | (year==1970)
replace CongTerm=92 if (year==1971) | (year==1972)
replace CongTerm=93 if (year==1973) | (year==1974)
replace CongTerm=94 if (year==1975) | (year==1976)
replace CongTerm=95 if (year==1977) | (year==1978)
replace CongTerm=96 if (year==1979) | (year==1980)
replace CongTerm=97 if (year==1981) | (year==1982)
replace CongTerm=98 if (year==1983) | (year==1984)
replace CongTerm=99 if (year==1985) | (year==1986)
replace CongTerm=100 if (year==1987) | (year==1988)
replace CongTerm=101 if (year==1989) | (year==1990)
replace CongTerm=102 if (year==1991) | (year==1992)
replace CongTerm=103 if (year==1993) | (year==1994)
replace CongTerm=104 if (year==1995) | (year==1996)
replace CongTerm=105 if (year==1997) | (year==1998)
replace CongTerm=106 if (year==1999) | (year==2000)
replace CongTerm=107 if (year==2001) | (year==2002)
replace CongTerm=108 if (year==2003) | (year==2004)
replace CongTerm=109 if (year==2005) | (year==2006)
replace CongTerm=110 if (year==2007) | (year==2008)
replace CongTerm=111 if (year==2009) | (year==2010)
replace CongTerm=112 if (year==2011) | (year==2012)
replace CongTerm=113 if (year==2013) | (year==2014)
replace CongTerm=114 if (year==2015) | (year==2016)

*Generate Majority Status variable
gen majority = 0
replace majority=1 if whitehouse==1 & house==1 & senate==1
gen congressmaj = 0
replace congressmaj=1 if house==1 & senate==1

*Generate CampaignTarget variable
gen campaigntarget = 0
replace campaigntarget=1 if target==1
replace campaigntarget=1 if campaign==1
replace campaigntarget=1 if mobil==1

*Generate Branding Activities variable
gen branding = 0
replace branding=1 if attack==1
replace branding=1 if pub==1
replace branding=1 if policy==1

*Generate Service Activities variable 
gen service = 0
replace service=1 if campaigntarget==1
replace service=1 if human==1
replace service=1 if recruit==1
replace service=1 if fund==1

*Generate Non-Branding Activities variable 
gen nonbranding = 0
replace nonbranding=1 if campaigntarget==1
replace nonbranding=1 if human==1
replace nonbranding=1 if recruit==1
replace nonbranding=1 if fund==1
replace nonbranding=1 if patronage==1
replace nonbranding=1 if convention==1

*Generate Other Activities variable
gen other = 0
replace other=1 if patronage==1
replace other=1 if generic==1
replace other=1 if convention==1

*Generate Sum of Activities variables 
gen brandingsum = 0
replace brandingsum = attack + pub + policy
gen nonbrandingsum = 0
replace nonbrandingsum = campaigntarget + human + recruit + fund + patronage + convention
gen servicesum = 0
replace servicesum = campaigntarget + human + recruit + fund
gen othersum = 0
replace othersum = patronage + generic + convention
gen allsum = 0
replace allsum = brandingsum + servicesum + othersum
gen nongeneric = 0
replace nongeneric = brandingsum + servicesum + patronage + convention
gen brandingservice = 0
replace brandingservice = brandingsum + servicesum

*Generate Minority President
gen minpres = 0
replace minpres = 1 if (majority==0 & whitehouse==1)

collapse (sum) majority branding nonbranding service other brandingsum nonbrandingsum servicesum brandingservice othersum allsum attack pub ///
policy target campaign campaigntarget human recruit mobil fund patronage generic convention presey midey whitehouse house senate congressmaj /// 
minpres scandal wilson harding coolidge hoover roosevelt truman eisenhower kennedy johnson nixon ford carter reagan hwbush clinton wbush obama trump ///
mccombs mccormick cummings gwhite hull shaver raskob farley flynn walker hannegan mcgrath boyle mckinney mitchell pbutler jackson bailey obrien1 ///
harris obrien2 obrientot westwood strauss curtis jcwhite manatt kirk brown wilhelm delee dodd_fowler romer_gross rendell_andrew mcauliffe dean ///
kaine wasserman brazile hilles wilcox hays adams wmbutler work huston fess sanders fletcher hamilton martin spangler brownell reece scott gabrielson summerfield ///
roberts hall alcorn tbmorton miller burch bliss rmorton dole bush smith brock richards fahrenkopf atwater yeutter bond barbour nicholson gilmore racicot ///
gillespie mehlman martinez duncan steele priebus (mean) length, by(CongTerm dem) 
replace majority = 1 if majority > 1 & majority != .
replace presey = 1 if presey > 1 & presey != .
replace midey = 1 if midey > 1 & midey != .
replace whitehouse = 1 if whitehouse > 1 & whitehouse != .
replace house = 1 if house > 1 & house != .
replace senate = 1 if senate > 1 & senate != .
replace congressmaj = 1 if congressmaj > 1 & congressmaj !=.
replace minpres = 1 if minpres > 1 & minpres !=.
replace wilson = 1 if wilson > 1 & wilson !=.
replace harding = 1 if harding > 1 & harding !=.
replace coolidge = 1 if coolidge > 1 & coolidge !=.
replace hoover = 1 if hoover > 1 & hoover !=.
replace roosevelt = 1 if roosevelt > 1 & roosevelt !=.
replace truman = 1 if truman > 1 & truman !=.
replace eisenhower = 1 if eisenhower > 1 & eisenhower !=.
replace kennedy = 1 if kennedy > 1 & kennedy !=.
replace johnson = 1 if johnson > 1 & johnson !=.
replace nixon = 1 if nixon > 1 & nixon !=.
replace ford = 1 if ford > 1 & ford !=.
replace carter = 1 if carter > 1 & carter !=.
replace reagan = 1 if reagan > 1 & reagan !=.
replace hwbush = 1 if hwbush > 1 & hwbush !=.
replace clinton = 1 if clinton > 1 & clinton !=.
replace wbush = 1 if wbush > 1 & wbush !=.
replace obama = 1 if obama > 1 & obama !=.
replace trump = 1 if trump > 1 & trump !=.
replace mccombs = 1 if mccombs > 1 & mccombs !=.
replace mccormick = 1 if mccormick > 1 & mccormick !=.
replace cummings = 1 if cummings > 1 & cummings !=.
replace gwhite = 1 if gwhite > 1 & gwhite !=.
replace hull = 1 if hull > 1 & hull !=.
replace shaver = 1 if shaver > 1 & shaver !=.
replace raskob = 1 if raskob > 1 & raskob !=.
replace farley = 1 if farley > 1 & farley !=.
replace flynn = 1 if flynn > 1 & flynn !=.
replace walker = 1 if walker > 1 & walker !=.
replace hannegan = 1 if hannegan > 1 & hannegan !=.
replace mcgrath = 1 if mcgrath > 1 & mcgrath !=.
replace boyle = 1 if boyle > 1 & boyle !=.
replace mckinney = 1 if mckinney > 1 & mckinney !=.
replace mitchell = 1 if mitchell > 1 & mitchell !=.
replace pbutler = 1 if pbutler > 1 & pbutler !=.
replace jackson = 1 if jackson > 1 & jackson !=.
replace bailey = 1 if bailey > 1 & bailey !=.
replace obrien1 = 1 if obrien1 > 1 & obrien1 !=.
replace harris = 1 if harris > 1 & harris !=.
replace obrien2 = 1 if obrien2 > 1 & obrien2 !=.
replace obrientot = 1 if obrientot > 1 & obrientot !=.
replace westwood = 1 if westwood > 1 & westwood !=.
replace strauss = 1 if strauss > 1 & strauss !=.
replace curtis = 1 if curtis > 1 & curtis !=.
replace jcwhite = 1 if jcwhite > 1 & jcwhite !=.
replace manatt = 1 if manatt > 1 & manatt !=.
replace kirk = 1 if kirk > 1 & kirk !=.
replace brown = 1 if brown > 1 & brown !=.
replace wilhelm = 1 if wilhelm > 1 & wilhelm !=.
replace delee = 1 if delee > 1 & delee !=.
replace dodd_fowler = 1 if dodd_fowler > 1 & dodd_fowler !=.
replace romer_gross = 1 if romer_gross > 1 & romer_gross !=.
replace rendell_andrew = 1 if rendell_andrew > 1 & rendell_andrew !=.
replace mcauliffe = 1 if mcauliffe > 1 & mcauliffe !=.
replace dean = 1 if dean > 1 & dean !=.
replace kaine = 1 if kaine > 1 & kaine !=.
replace wasserman = 1 if wasserman > 1 & wasserman !=.
replace brazile = 1 if brazile > 1 & brazile !=.
replace hilles = 1 if hilles > 1 & hilles !=.
replace wilcox = 1 if wilcox > 1 & wilcox !=.
replace hays = 1 if hays > 1 & hays !=.
replace adams = 1 if adams > 1 & adams !=.
replace wmbutler = 1 if wmbutler > 1 & wmbutler !=.
replace work = 1 if work > 1 & work !=.
replace huston = 1 if huston > 1 & huston !=.
replace fess = 1 if fess > 1 & fess !=.
replace sanders = 1 if sanders > 1 & sanders !=.
replace fletcher = 1 if fletcher > 1 & fletcher !=.
replace hamilton = 1 if hamilton > 1 & hamilton !=.
replace martin = 1 if martin > 1 & martin !=.
replace spangler = 1 if spangler > 1 & spangler !=.
replace brownell = 1 if brownell > 1 & brownell !=.
replace reece = 1 if reece > 1 & reece !=.
replace scott = 1 if scott > 1 & scott !=.
replace gabrielson = 1 if gabrielson > 1 & gabrielson !=.
replace summerfield = 1 if summerfield > 1 & summerfield !=.
replace roberts = 1 if roberts > 1 & roberts !=.
replace hall = 1 if hall > 1 & hall !=.
replace alcorn = 1 if alcorn > 1 & alcorn !=.
replace tbmorton = 1 if tbmorton > 1 & tbmorton !=.
replace miller = 1 if miller > 1 & miller !=.
replace burch = 1 if burch > 1 & burch !=.
replace bliss = 1 if bliss > 1 & bliss !=.
replace rmorton = 1 if rmorton > 1 & rmorton !=.
replace dole = 1 if dole > 1 & dole !=.
replace bush = 1 if bush > 1 & bush !=.
replace smith = 1 if smith > 1 & smith !=.
replace brock = 1 if brock > 1 & brock !=.
replace richards = 1 if richards > 1 & richards !=.
replace fahrenkopf = 1 if fahrenkopf > 1 & fahrenkopf !=.
replace atwater = 1 if atwater > 1 & atwater !=.
replace yeutter = 1 if yeutter > 1 & yeutter !=.
replace bond = 1 if bond > 1 & bond !=.
replace barbour = 1 if barbour > 1 & barbour !=.
replace nicholson = 1 if nicholson > 1 & nicholson !=.
replace gilmore = 1 if gilmore > 1 & gilmore !=.
replace racicot = 1 if racicot > 1 & racicot !=.
replace gillespie = 1 if gillespie > 1 & gillespie !=.
replace mehlman = 1 if mehlman > 1 & mehlman !=.
replace martinez = 1 if martinez > 1 & martinez !=.
replace duncan = 1 if duncan > 1 & duncan !=.
replace steele = 1 if steele > 1 & steele !=.
replace priebus = 1 if priebus > 1 & priebus !=.

*Jeffords Exception
replace majority = 0 if (CongTerm==107 & dem==0)
replace senate = 0 if (CongTerm==107 & dem==0)

label variable majority "Majority President" 
label variable minpres "Minority President" 
label variable presey "Presidential Election"
label variable midey "Midterm Election"
label variable whitehouse "White House"
label variable house "House Majority"
label variable senate "Senate Majority"
label variable congressmaj "Congressional Majority"
label variable dem "Democratic Party"
label variable length "NYT Length"
label variable scandal "Scandal"
label variable CongTerm "Congressional Term"

save Data_1913_2016_CT.dta, replace  

use Data_1913_2016_CT.dta  
xi: nbreg brandingsum whitehouse presey midey dem length scandal, robust
coefplot, keep(brandingsum whitehouse presey midey dem length scandal) xline (0) title("Control Variables")
graph save ct1, replace
xi: nbreg brandingsum whitehouse dem scandal i.CongTerm, robust
coefplot, keep(brandingsum whitehouse dem scandal) xline (0) title("Fixed Effects")
graph save ct2, replace
xi: nbreg brandingsum majority  minpres presey midey dem length scandal, robust
coefplot, keep(brandingsum majority minpres presey midey dem length scandal) xline (0)
graph save ct3, replace
xi: nbreg brandingsum majority minpres dem scandal i.CongTerm, robust
coefplot, keep(brandingsum majority minpres dem scandal) xline (0)
graph save ct4, replace
gr combine ct1.gph ct2.gph ct3.gph ct4.gph, col(2) iscale(1)
graph save FigureA_2_3.gph, replace
graph export FigureA_2_3.png, replace 

* Chapter 3: DNC and RNC 1912-1932

* Update NYT Data for CH 3
use Data_1913_2016_3.dta
gen White_Hull = 0
replace White_Hull=1 if gwhite==1 
replace White_Hull=1 if hull==1 
gen coolidgeterm2 = 0
replace coolidgeterm2=1 if (coolidge==1) & (year==1924) & (presey==0)
replace coolidgeterm2=1 if (coolidge==1) & (year==1925)
replace coolidgeterm2=1 if (coolidge==1) & (year==1926)
replace coolidgeterm2=1 if (coolidge==1) & (year==1927)
replace coolidgeterm2=1 if (coolidge==1) & (year==1928) & (presey==1)
label variable White_Hull "White & Hull"
label variable coolidgeterm2 "Coolidge term 2"
label variable raskob "Raskob"
label variable harding "Harding"
label variable coolidge "Coolidge"
save Data_1913_2016_CH3.dta, replace

* Figure 3.1: Democratic Electoral Performance, 1912-1932
use ElectoralPerformance.dta
line pvperc_d houseperc_d senateperc_d year if (inrange(year, 1912,1932)), yscale(range (0 100)) ylabel(0 (10) 100) xlabel(1912(4)1932) xtitle("") lpattern (solid dash shortdash) yline(50, lcolor(red)) legend( region(lcolor(white)))
graph save Figure3_1, replace
graph export Figure3_1.png, replace 

* Figure 3.2: White and Hull vs. Wilson-era, 1913-1924
use Data_1913_2016_CH3.dta
xi: nbreg lag_brandingsum White_Hull presey midey length scandal if (inrange(year, 1917,1924) & dem==1 & shaver==0), robust
estimates store Branding
xi: nbreg lag_servicesum White_Hull presey midey length scandal if (inrange(year, 1917,1924) & dem==1 & shaver==0), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure3_2_a, replace
xi: nbreg lag_attack White_Hull presey midey length scandal if (inrange(year, 1917,1924) & dem==1 & shaver==0), robust
estimates store Attack
xi: nbreg lag_pub White_Hull presey midey length scandal if (inrange(year, 1917,1924) & dem==1 & shaver==0), robust
estimates store Publicity
xi: nbreg lag_policy White_Hull presey midey length scandal if (inrange(year, 1917,1924) & dem==1 & shaver==0), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure3_2_b, replace
gr combine Figure3_2_a.gph Figure3_2_b.gph, iscale(1)
graph save Figure3_2, replace
graph export Figure3_2.png, replace 

* Figure 3.3: Raskob vs. Shaver, 1925-1932
use Data_1913_2016_CH3.dta
xi: nbreg lag_brandingsum raskob presey midey length scandal if (inrange(year, 1925,1932) & dem==1 & farley==0), robust
estimates store Branding
xi: nbreg lag_servicesum raskob presey midey length scandal if (inrange(year, 1925,1932) & dem==1 & farley==0), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 8)) xlabel(-3[1]8) legend( region(lcolor(white)))
graph save Figure3_3_a, replace
xi: nbreg lag_attack raskob presey midey length scandal if (inrange(year, 1925,1932) & dem==1 & farley==0), robust
estimates store Attack
xi: nbreg lag_pub raskob presey midey length scandal if (inrange(year, 1925,1932) & dem==1 & farley==0), robust
estimates store Publicity
xi: nbreg lag_policy raskob presey midey length scandal if (inrange(year, 1925,1932) & dem==1 & farley==0), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 8)) xlabel(-3[1]8) legend( region(lcolor(white)))
graph save Figure3_3_b, replace
gr combine Figure3_3_a.gph Figure3_3_b.gph, iscale(1)
graph save Figure3_3, replace
graph export Figure3_3.png, replace 

* Figure 3.4: Republican Electoral Performance, 1912-1932
use ElectoralPerformance.dta
line pvperc_r houseperc_r senateperc_r year if (inrange(year, 1912,1932)), yscale(range (0 100)) ylabel(0 (10) 100) xlabel(1912(4)1932) xtitle("") lpattern (solid dash shortdash) yline(50, lcolor(red)) legend( region(lcolor(white)))
graph save Figure3_4, replace
graph export Figure3_4.png, replace 

* Figure 3.5: Coolidge vs. Harding , 1921-1928
use Data_1913_2016_CH3.dta
xi: nbreg lag_brandingsum coolidgeterm2 presey midey length scandal if (inrange(year, 1921,1928) & dem==0), robust
estimates store Branding
xi: nbreg lag_servicesum coolidgeterm2 presey midey length scandal  if (inrange(year, 1921,1928) & dem==0), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-7 3)) xlabel(-7[1]3) legend( region(lcolor(white)))
graph save Figure3_5_a, replace
xi: nbreg lag_attack coolidgeterm2 presey midey length scandal if (inrange(year, 1921,1928) & dem==0), robust
estimates store Attack
xi: nbreg lag_pub coolidgeterm2 presey midey length scandal if (inrange(year, 1921,1928) & dem==0), robust
estimates store Publicity
xi: nbreg lag_policy coolidgeterm2 presey midey length scandal if (inrange(year, 1921,1928) & dem==0), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-6 3)) xlabel(-6[1]3) legend( region(lcolor(white)))
graph save Figure3_5_b, replace
gr combine Figure3_5_a.gph Figure3_5_b.gph, iscale(1)
graph save Figure3_5, replace
graph export Figure3_5.png, replace 

* Chapter 4: DNC and RNC, 1933-1952

* Update NYT Data for CH 5
use Data_1913_2016_3.dta
gen FDR1 = 0
replace FDR1=1 if (roosevelt==1) & (year==1932) & (presey==0)
replace FDR1=1 if (roosevelt==1) & (year==1933)
replace FDR1=1 if (roosevelt==1) & (year==1934)
replace FDR1=1 if (roosevelt==1) & (year==1935)
replace FDR1=1 if (roosevelt==1) & (year==1936) & (presey==1)
gen FDR2 = 0
replace FDR2=1 if (roosevelt==1) & (year==1936) & (presey==0)
replace FDR2=1 if (roosevelt==1) & (year==1937)
replace FDR2=1 if (roosevelt==1) & (year==1938)
replace FDR2=1 if (roosevelt==1) & (year==1939)
replace FDR2=1 if (roosevelt==1) & (year==1940) & (presey==1)
label variable FDR1 "FDR term 1"
label variable FDR2 "FDR term 2"
label variable fletcher "Fletcher"
label variable truman "Truman"
label variable gabrielson "Gabrielson"
save Data_1913_2016_CH4.dta, replace

* Figure 4.1: FDR vs. DNC out-years, 1929-1936
use Data_1913_2016_CH4.dta
xi: nbreg lag_brandingsum FDR1 presey midey length scandal if (inrange(year, 1929,1936) & dem==1), robust
estimates store Branding
xi: nbreg lag_servicesum FDR1 presey midey length scandal if (inrange(year, 1929,1936) & dem==1), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure4_1_a, replace
xi: nbreg lag_attack FDR1 presey midey length scandal if (inrange(year, 1929,1936) & dem==1), robust
estimates store Attack
xi: nbreg lag_pub FDR1 presey midey length scandal if (inrange(year, 1929,1936) & dem==1), robust
estimates store Publicity
xi: nbreg lag_policy FDR1 presey midey length scandal if (inrange(year, 1929,1936) & dem==1), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure4_1_b, replace
gr combine Figure4_1_a.gph Figure4_1_b.gph, iscale(1)
graph save Figure4_1, replace
graph export Figure4_1.png, replace 

* Figure 4.2: Democratic Electoral Performance, 1932-1952
use ElectoralPerformance.dta
line pvperc_d houseperc_d senateperc_d year if (inrange(year, 1932,1952)), yscale(range (0 100)) ylabel(0 (10) 100) xlabel(1932(4)1952) xtitle("") lpattern (solid dash shortdash) yline(50, lcolor(red)) legend( region(lcolor(white)))
graph save Figure4_2, replace
graph export Figure4_2.png, replace 

* Figure 4.3: FDR term 2 vs. FDR term 1, 1933-1940
use Data_1913_2016_CH4.dta
xi: nbreg lag_brandingsum FDR2 presey midey length scandal if (inrange(year, 1933,1940) & dem==1), robust
estimates store Branding
xi: nbreg lag_servicesum FDR2 presey midey length scandal if (inrange(year, 1933,1940) & dem==1), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure4_3_a, replace
xi: nbreg lag_attack FDR2 presey midey length scandal if (inrange(year, 1933,1940) & dem==1), robust
estimates store Attack
xi: nbreg lag_pub FDR2 presey midey length scandal if (inrange(year, 1933,1940) & dem==1), robust
estimates store Publicity
xi: nbreg lag_policy FDR2 presey midey length scandal if (inrange(year, 1933,1940) & dem==1), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure4_3_b, replace
gr combine Figure4_3_a.gph Figure4_3_b.gph, iscale(1)
graph save Figure4_3, replace
graph export Figure4_3.png, replace 

* Figure 4.4: Republican Electoral Performance, 1932-1952
use ElectoralPerformance.dta
line pvperc_r houseperc_r senateperc_r year if (inrange(year, 1932,1952)), yscale(range (0 100)) ylabel(0 (10) 100) xlabel(1932(4)1952) xtitle("") lpattern (solid dash shortdash) yline(50, lcolor(red)) legend( region(lcolor(white)))
graph save Figure4_4, replace
graph export Figure4_4.png, replace 

*Figure 4.5: Fletcher vs. Sanders, 1933-1936
use Data_1913_2016_CH4.dta
xi: nbreg lag_brandingsum fletcher presey midey length scandal if (inrange(year, 1933,1936) & dem==0 & hamilton==0), robust
estimates store Branding
xi: nbreg lag_servicesum fletcher presey midey length scandal if (inrange(year, 1933,1936) & dem==0 & hamilton==0), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure4_5_a, replace
xi: nbreg lag_attack fletcher presey midey length scandal if (inrange(year, 1933,1936) & dem==0 & hamilton==0), robust
estimates store Attack
xi: nbreg lag_pub fletcher presey midey length scandal if (inrange(year, 1933,1936) & dem==0 & hamilton==0), robust
estimates store Publicity
xi: nbreg lag_policy fletcher presey midey length scandal if (inrange(year, 1933,1936) & dem==0 & hamilton==0), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure4_5_b, replace
gr combine Figure4_5_a.gph Figure4_5_b.gph, iscale(1)
graph save Figure4_5, replace
graph export Figure4_5.png, replace 

* Figure 4.6: Gabrielson vs. Out-RNC chairs, 1945-1952
use Data_1913_2016_CH4.dta
xi: nbreg lag_brandingsum gabrielson presey midey length scandal  if (inrange(year, 1945,1952) & dem==0 & summerfield==0), robust
estimates store Branding
xi: nbreg lag_servicesum gabrielson presey midey length scandal  if (inrange(year, 1945,1952) & dem==0 & summerfield==0), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure4_6_a, replace
xi: nbreg lag_attack gabrielson presey midey length scandal if (inrange(year, 1945,1952) & dem==0 & summerfield==0), robust
estimates store Attack
xi: nbreg lag_pub gabrielson presey midey length scandal if (inrange(year, 1945,1952) & dem==0 & summerfield==0), robust
estimates store Publicity
xi: nbreg lag_policy gabrielson presey midey length scandal if (inrange(year, 1945,1952) & dem==0 & summerfield==0), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure4_6_b, replace
gr combine Figure4_6_a.gph Figure4_6_b.gph, iscale(1)
graph save Figure4_6, replace
graph export Figure4_6.png, replace 

* Chapter 5: DNC and RNC, 1953-1968

* Update NYT Data for CH 5
use Data_1913_2016_3.dta
gen eisenhower1 = 0
replace eisenhower1=1 if (eisenhower==1) & (year==1952) & (presey==0)
replace eisenhower1=1 if (eisenhower==1) & (year==1953)
replace eisenhower1=1 if (eisenhower==1) & (year==1954)
replace eisenhower1=1 if (eisenhower==1) & (year==1955)
replace eisenhower1=1 if (eisenhower==1) & (year==1956) & (presey==1)
gen mortonmiller = 0
replace mortonmiller=1 if tbmorton==1 
replace mortonmiller=1 if miller==1 
label variable mitchell "Mitchell"
label variable pbutler "Butler"
label variable eisenhower1 "Eisenhower term 1"
label variable kennedy "Kennedy"
label variable mortonmiller "Morton & Miller"
save Data_1913_2016_CH5.dta, replace

* Figure 5.1: Democratic Electoral Performance, 1952-1968
use ElectoralPerformance.dta
line pvperc_d houseperc_d senateperc_d year if (inrange(year, 1952,1968)), yscale(range (0 100)) ylabel(0 (10) 100) xlabel(1952(4)1968) xtitle("") lpattern (solid dash shortdash) yline(50, lcolor(red)) legend( region(lcolor(white)))
graph save Figure5_1, replace
graph export Figure5_1.png, replace 

* Figure 5.2: Mitchell vs. Truman, 1949-1956
use Data_1913_2016_CH5.dta
xi: nbreg lag_brandingsum mitchell presey midey length scandal if (inrange(year, 1949,1954) & dem==1 & pbutler==0), robust
estimates store Branding
xi: nbreg lag_servicesum mitchell presey midey length scandal if (inrange(year, 1949,1954) & dem==1 & pbutler==0), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure5_2_a, replace
xi: nbreg lag_attack mitchell presey midey length scandal if (inrange(year, 1949,1954) & dem==1 & pbutler==0), robust
estimates store Attack
xi: nbreg lag_pub mitchell presey midey length scandal if (inrange(year, 1949,1954) & dem==1 & pbutler==0), robust
estimates store Publicity
xi: nbreg lag_policy mitchell presey midey length scandal if (inrange(year, 1949,1954) & dem==1 & pbutler==0), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure5_2_b, replace
gr combine Figure5_2_a.gph Figure5_2_b.gph, iscale(1)
graph save Figure5_2, replace
graph export Figure5_2.png, replace 

* Figure 5.3: Butler vs. Mitchell/Butler, 1953-1960
use Data_1913_2016_CH5.dta
xi: nbreg lag_brandingsum pbutler presey midey length scandal if (inrange(year, 1953,1960) & dem==1 & jackson==0 & whitehouse==0), robust
estimates store Branding
xi: nbreg lag_servicesum pbutler presey midey length scandal if (inrange(year, 1953,1960) & dem==1 & jackson==0 & whitehouse==0), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure5_3_a, replace
xi: nbreg lag_attack pbutler presey midey length scandal if (inrange(year, 1953,1960) & dem==1 & jackson==0 & whitehouse==0), robust
estimates store Attack
xi: nbreg lag_pub pbutler presey midey length scandal if (inrange(year, 1953,1960) & dem==1 & jackson==0 & whitehouse==0), robust
estimates store Publicity
xi: nbreg lag_policy pbutler presey midey length scandal if (inrange(year, 1953,1960) & dem==1 & jackson==0 & whitehouse==0), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure5_3_b, replace
gr combine Figure5_3_a.gph Figure5_3_b.gph, iscale(1)
graph save Figure5_3, replace
graph export Figure5_3.png, replace 

* Figure 5.4: Republican Electoral Performance, 1952-1968
use ElectoralPerformance.dta
line pvperc_r houseperc_r senateperc_r year if (inrange(year, 1952,1968)), yscale(range (0 100)) ylabel(0 (10) 100) xlabel(1952(4)1968) xtitle("") lpattern (solid dash shortdash) yline(50, lcolor(red)) legend( region(lcolor(white)))
graph save Figure5_4, replace
graph export Figure5_4.png, replace 

* Figure 5.5: Eisenhower vs. Out-RNC, 1949-1956
use Data_1913_2016_CH5.dta
xi: nbreg lag_brandingsum eisenhower1 presey midey length scandal  if (inrange(year, 1949,1956) & dem==0), robust
estimates store Branding
xi: nbreg lag_servicesum eisenhower1 presey midey length scandal  if (inrange(year, 1949,1956) & dem==0), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure5_5_a, replace
xi: nbreg lag_attack eisenhower1 presey midey length scandal if (inrange(year, 1949,1956) & dem==0), robust
estimates store Attack
xi: nbreg lag_pub eisenhower1 presey midey length scandal if (inrange(year, 1949,1956) & dem==0), robust
estimates store Publicity
xi: nbreg lag_policy eisenhower1 presey midey length scandal if (inrange(year, 1949,1956) & dem==0), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure5_5_b, replace
gr combine Figure5_5_a.gph Figure5_5_b.gph, iscale(1)
graph save Figure5_5, replace
graph export Figure5_5.png, replace 

* Figure 5.6: Kennedy vs. Butler, 1957-1963
use Data_1913_2016_CH5.dta
xi: nbreg lag_brandingsum kennedy presey midey length scandal if (inrange(year, 1957,1963) & dem==1 & johnson==0), robust
estimates store Branding
xi: nbreg lag_servicesum kennedy presey midey length scandal if (inrange(year, 1957,1963) & dem==1 & johnson==0), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure5_6_a, replace
xi: nbreg lag_attack kennedy presey midey length scandal if (inrange(year, 1957,1963) & dem==1 & johnson==0), robust
estimates store Attack
xi: nbreg lag_pub kennedy presey midey length scandal if (inrange(year, 1957,1963) & dem==1 & johnson==0), robust
estimates store Publicity
xi: nbreg lag_policy kennedy presey midey length scandal if (inrange(year, 1957,1963) & dem==1 & johnson==0), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure5_6_b, replace
gr combine Figure5_6_a.gph Figure5_6_b.gph, iscale(1)
graph save Figure5_6, replace
graph export Figure5_6.png, replace 

* Figure 5.7: Morton and Miller vs. Eisenhower, 1957-1964
use Data_1913_2016_CH5.dta
xi: nbreg lag_brandingsum mortonmiller presey midey length scandal  if (inrange(year, 1957,1964) & dem==0 & burch==0), robust
estimates store Branding
xi: nbreg lag_servicesum mortonmiller presey midey length scandal  if (inrange(year, 1957,1964) & dem==0 & burch==0), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure5_7_a, replace
xi: nbreg lag_attack mortonmiller presey midey length scandal if (inrange(year, 1957,1964) & dem==0 & burch==0), robust
estimates store Attack
xi: nbreg lag_pub mortonmiller presey midey length scandal if (inrange(year, 1957,1964) & dem==0 & burch==0), robust
estimates store Publicity
xi: nbreg lag_policy mortonmiller presey midey length scandal if (inrange(year, 1957,1964) & dem==0 & burch==0), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure5_7_b, replace
gr combine Figure5_7_a.gph Figure5_7_b.gph, iscale(1)
graph save Figure5_7, replace
graph export Figure5_7.png, replace 

* Chapter 6: DNC and RNC, 1969-1980

* Update NYT Data for CH 6
use Data_1913_2016_3.dta
gen OBrien_Harris = 0
replace OBrien_Harris=1 if obrientot==1 
replace OBrien_Harris=1 if harris==1 
gen nixon1 = 0
replace nixon1=1 if (year==1968) & presey==0 & dem==0
replace nixon1=1 if (year==1969) & dem==0
replace nixon1=1 if (year==1970) & dem==0
replace nixon1=1 if (year==1971) & dem==0
replace nixon1=1 if (year==1972) & presey==1 & dem==0
gen nixonford = 0
replace nixonford=1 if (nixon==1) & (nixon1==0)
replace nixonford=1 if (ford==1)
label variable OBrien_Harris "O'Brien & Harris"
label variable nixon1 "Nixon term 1" 
label variable nixonford "Nixon & Ford"
label variable brock "Brock"
label variable carter "Carter"
save Data_1913_2016_CH6.dta, replace

* Figure 6.1: Democratic Electoral Performance, 1968-1980
use ElectoralPerformance.dta
line pvperc_d houseperc_d senateperc_d year if (inrange(year, 1968,1980)), yscale(range (0 100)) ylabel(0 (10) 100) xlabel(1968(4)1980) xtitle("") lpattern (solid dash shortdash) yline(50, lcolor(red)) legend( region(lcolor(white)))
graph save Figure6_1, replace
graph export Figure6_1.png, replace 

* Figure 6.2: O'Brien and Harris vs. Johnson, 1965-1972
use Data_1913_2016_CH6.dta
xi: nbreg lag_brandingsum OBrien_Harris presey midey length scandal if (inrange(year, 1965,1972) & dem==1 & westwood==0 & strauss==0), robust
estimates store Branding
xi: nbreg lag_servicesum OBrien_Harris presey midey length scandal if (inrange(year, 1965,1972) & dem==1 & westwood==0 & strauss==0), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure6_2_a, replace
xi: nbreg lag_attack OBrien_Harris presey midey length scandal if (inrange(year, 1965,1972) & dem==1 & westwood==0 & strauss==0), robust
estimates store Attack
xi: nbreg lag_pub OBrien_Harris presey midey length scandal if (inrange(year, 1965,1972) & dem==1 & westwood==0 & strauss==0), robust
estimates store Publicity
xi: nbreg lag_policy OBrien_Harris presey midey length scandal if (inrange(year, 1965,1972) & dem==1 & westwood==0 & strauss==0), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure6_2_b, replace
gr combine Figure6_2_a.gph Figure6_2_b.gph, iscale(1)
graph save Figure6_2, replace
graph export Figure6_2.png, replace 

* Figure 6.3: Republican Electoral Performance, 1968-1980
use ElectoralPerformance.dta
line pvperc_r houseperc_r senateperc_r year if (inrange(year, 1968,1980)), yscale(range (0 100)) ylabel(0 (10) 100) xlabel(1968(4)1980) xtitle("") lpattern (solid dash shortdash) yline(50, lcolor(red)) legend( region(lcolor(white)))
graph save Figure6_3, replace
graph export Figure6_3.png, replace 

* Figure 6.4: Nixon Term 1 vs. Bliss, 1965-1972
use Data_1913_2016_CH6.dta
xi: nbreg lag_brandingsum nixon1 presey midey length scandal  if (inrange(year, 1965,1972) & dem==0), robust
estimates store Branding
xi: nbreg lag_servicesum nixon1 presey midey length scandal   if (inrange(year, 1965,1972) & dem==0), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure6_4_a, replace
xi: nbreg lag_attack nixon1 presey midey length scandal  if (inrange(year, 1965,1972) & dem==0), robust
estimates store Attack
xi: nbreg lag_pub nixon1 presey midey length scandal  if (inrange(year, 1965,1972) & dem==0), robust
estimates store Publicity
xi: nbreg lag_policy nixon1 presey midey length scandal  if (inrange(year, 1965,1972) & dem==0), robust
estimates store Policy 
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 4)) xlabel(-3[1]4) legend( region(lcolor(white)))
graph save Figure6_4_b, replace
gr combine Figure6_4_a.gph Figure6_4_b.gph, iscale(1)
graph save Figure6_4, replace
graph export Figure6_4.png, replace 

* Figure 6.5: Nixon and Ford Term (Post-1972 Election) vs. Nixon Term 1, 1969-1976
use Data_1913_2016_CH6.dta
xi: nbreg lag_brandingsum nixonford presey midey length scandal  if (inrange(year, 1969,1976) & dem==0), robust
estimates store Branding
xi: nbreg lag_servicesum nixonford presey midey length scandal   if (inrange(year, 1969,1976) & dem==0), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure6_5_a, replace
xi: nbreg lag_attack nixonford presey midey length scandal  if (inrange(year, 1969,1976) & dem==0), robust
estimates store Attack
xi: nbreg lag_pub nixonford presey midey length scandal  if (inrange(year, 1969,1976) & dem==0), robust
estimates store Publicity
xi: nbreg lag_policy nixonford presey midey length scandal  if (inrange(year, 1969,1976) & dem==0), robust
estimates store Policy 
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 4)) xlabel(-3[1]4) legend( region(lcolor(white)))
graph save Figure6_5_b, replace
gr combine Figure6_5_a.gph Figure6_5_b.gph, iscale(1)
graph save Figure6_5, replace
graph export Figure6_5.png, replace 

* Figure 6.6: Brock vs. Nixon/Ford, 1973-1980
use Data_1913_2016_CH6.dta
xi: nbreg lag_brandingsum brock presey midey length scandal  if (inrange(year, 1973,1980) & dem==0 & reagan==0), robust
estimates store Branding
xi: nbreg lag_servicesum brock presey midey length scandal  if (inrange(year, 1973,1980) & dem==0 & reagan==0), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure6_6_a, replace
xi: nbreg lag_attack brock presey midey length scandal if (inrange(year, 1973,1980) & dem==0 & reagan==0), robust
estimates store Attack
xi: nbreg lag_pub brock presey midey length scandal if (inrange(year, 1973,1980) & dem==0 & reagan==0), robust
estimates store Publicity
xi: nbreg lag_policy brock presey midey length scandal if (inrange(year, 1973,1980) & dem==0 & reagan==0), robust
estimates store Policy 
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 4)) xlabel(-3[1]4) legend( region(lcolor(white)))
graph save Figure6_6_b, replace
gr combine Figure6_6_a.gph Figure6_6_b.gph, iscale(1)
graph save Figure6_6, replace
graph export Figure6_6.png, replace 

* Figure 6.7: Carter vs. Strauss, 1973-1980
use Data_1913_2016_CH6.dta
xi: nbreg lag_brandingsum carter presey midey length scandal if (inrange(year, 1973,1980) & dem==1), robust
estimates store Branding
xi: nbreg lag_servicesum carter presey midey length scandal if (inrange(year, 1973,1980) & dem==1), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure6_7_a, replace
xi: nbreg lag_attack carter presey midey length scandal if (inrange(year, 1973,1980) & dem==1), robust
estimates store Attack
xi: nbreg lag_pub carter presey midey length scandal if (inrange(year, 1973,1980) & dem==1), robust
estimates store Publicity
xi: nbreg lag_policy carter presey midey length scandal if (inrange(year, 1973,1980) & dem==1), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-5 3)) xlabel(-5[1]3) legend( region(lcolor(white)))
graph save Figure6_7_b, replace
gr combine Figure6_7_a.gph Figure6_7_b.gph, iscale(1)
graph save Figure6_7, replace
graph export Figure6_7.png, replace 

* Chapter 7: DNC and RNC, 1981-2000

* Update NYT Data for CH 7
use Data_1913_2016_3.dta
gen reagan1 = 0
replace reagan1=1 if (year==1980) & presey==0 & dem==0
replace reagan1=1 if (year==1981) & dem==0
replace reagan1=1 if (year==1982) & dem==0
replace reagan1=1 if (year==1983) & dem==0
replace reagan1=1 if (year==1984) & presey==1 & dem==0
gen clinton1 = 0
replace clinton1=1 if (year==1992) & presey==0 & dem==1
replace clinton1=1 if (year==1993) & dem==1
replace clinton1=1 if (year==1994) & dem==1
replace clinton1=1 if (year==1995) & dem==1
replace clinton1=1 if (year==1996) & presey==1 & dem==1
gen clinton2 = 0
replace clinton2=1 if (year==1996) & presey==0 & dem==1
replace clinton2=1 if (year==1997) & dem==1
replace clinton2=1 if (year==1998) & dem==1
replace clinton2=1 if (year==1999) & dem==1
replace clinton2=1 if (year==2000) & presey==1 & dem==1
label variable reagan1 "Reagan term 1"
label variable manatt "Manatt" 
label variable barbour "Barbour"
label variable clinton1 "Clinton term 1"
label variable clinton2 "Clinton term 2"
save Data_1913_2016_CH7.dta, replace

* Figure 7.1: Democratic Electoral Performance, 1981-2000
use ElectoralPerformance.dta
line pvperc_d houseperc_d senateperc_d year if (inrange(year, 1980,2000)), yscale(range (0 100)) ylabel(0 (10) 100) xlabel(1980(4)2000) xtitle("") lpattern (solid dash shortdash) yline(50, lcolor(red)) legend( region(lcolor(white)))
graph save Figure7_1, replace
graph export Figure7_1.png, replace 

* Figure 7.2: Manatt vs. Carter, 1977-1984
use Data_1913_2016_CH7.dta
xi: nbreg lag_brandingsum manatt presey midey length scandal if (inrange(year, 1977,1984) & dem==1), robust
estimates store Branding
xi: nbreg lag_servicesum manatt presey midey length scandal if (inrange(year, 1977,1984) & dem==1), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure7_2_a, replace
xi: nbreg lag_attack manatt presey midey length scandal if (inrange(year, 1977,1984) & dem==1), robust
estimates store Attack
xi: nbreg lag_pub manatt presey midey length scandal if (inrange(year, 1977,1984) & dem==1), robust
estimates store Publicity
xi: nbreg lag_policy manatt presey midey length scandal if (inrange(year, 1977,1984) & dem==1), robust
estimates store Policy 
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 6)) xlabel(-3[1]6) legend( region(lcolor(white)))
graph save Figure7_2_b, replace
gr combine Figure7_2_a.gph Figure7_2_b.gph, iscale(1)
graph save Figure7_2, replace
graph export Figure7_2.png, replace 

* Figure 7.3: Republican Electoral Performance, 1981-2000
use ElectoralPerformance.dta
line pvperc_r houseperc_r senateperc_r year if (inrange(year, 1980,2000)), yscale(range (0 100)) ylabel(0 (10) 100) xlabel(1980(4)2000) xtitle("") lpattern (solid dash) yline(50, lcolor(red)) legend( region(lcolor(white)))
graph save Figure7_3, replace
graph export Figure7_3.png, replace 

* Figure 7.4: Reagan First Term vs. Brock, 1977-1984
use Data_1913_2016_CH7.dta
xi: nbreg lag_brandingsum reagan1 presey midey length scandal  if (inrange(year, 1977,1984) & dem==0), robust
estimates store Branding
xi: nbreg lag_servicesum reagan1 presey midey length scandal  if (inrange(year, 1977,1984) & dem==0), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure7_4_a, replace
xi: nbreg lag_attack reagan1 presey midey length scandal if (inrange(year, 1977,1984) & dem==0), robust
estimates store Attack
xi: nbreg lag_pub reagan1 presey midey length scandal if (inrange(year, 1977,1984) & dem==0), robust
estimates store Publicity
xi: nbreg lag_policy reagan1 presey midey length scandal if (inrange(year, 1977,1984) & dem==0), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure7_4_b, replace
gr combine Figure7_4_a.gph Figure7_4_b.gph, iscale(1)
graph save Figure7_4, replace
graph export Figure7_4.png, replace 

* Figure 7.5: Barbour vs. H.W. Bush, 1989-1996
use Data_1913_2016_CH7.dta
xi: nbreg lag_brandingsum barbour presey midey length scandal  if (inrange(year, 1989,1996) & dem==0), robust
estimates store Branding
xi: nbreg lag_servicesum barbour presey midey length scandal  if (inrange(year, 1989,1996) & dem==0), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure7_5_a, replace
xi: nbreg lag_attack barbour presey midey length scandal if (inrange(year, 1989,1996) & dem==0), robust
estimates store Attack
xi: nbreg lag_pub barbour presey midey length scandal if (inrange(year, 1989,1996) & dem==0), robust
estimates store Publicity
xi: nbreg lag_policy barbour presey midey length scandal if (inrange(year, 1989,1996) & dem==0), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure7_5_b, replace
gr combine Figure7_5_a.gph Figure7_5_b.gph, iscale(1)
graph save Figure7_5, replace
graph export Figure7_5.png, replace 

* Figure 7.6: First Clinton Term vs. Brown, 1989-1996
use Data_1913_2016_CH7.dta
xi: nbreg lag_brandingsum clinton1 presey midey length scandal if (inrange(year, 1989,1996) & dem==1), robust
estimates store Branding
xi: nbreg lag_servicesum clinton1 presey midey length scandal if (inrange(year, 1989,1996) & dem==1), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure7_6_a, replace
xi: nbreg lag_attack clinton1 presey midey length scandal if (inrange(year, 1989,1996) & dem==1), robust
estimates store Attack
xi: nbreg lag_pub clinton1 presey midey length scandal if (inrange(year, 1989,1996) & dem==1), robust
estimates store Publicity
xi: nbreg lag_policy clinton1 presey midey length scandal if (inrange(year, 1989,1996) & dem==1), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure7_6_b, replace
gr combine Figure7_6_a.gph Figure7_6_b.gph, iscale(1)
graph save Figure7_6, replace
graph export Figure7_6.png, replace 

* Figure 7.7: DNC Scandal, 1913-2016
use Data_1913_2016_Year.dta
drop if dem==0
label variable scandal "DNC Scandal Articles"
save Data_1913_2016_YearD.dta, replace 
line scandal year, yscale(range (0 80)) ylabel(0 (10) 80) xlabel(1912(8)2016) xtitle("") lpattern (solid dash) legend( region(lcolor(white)))
graph save Figure7_7, replace
graph export Figure7_7.png, replace 

* Figure 7.8: Second Clinton Term vs. First Clinton Term, 1993-2000
use Data_1913_2016_CH7.dta
xi: nbreg lag_brandingsum clinton2 presey midey length scandal if (inrange(year, 1993,2000) & dem==1), robust
estimates store Branding
xi: nbreg lag_servicesum clinton2 presey midey length scandal if (inrange(year, 1993,2000) & dem==1), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure7_8_a, replace
xi: nbreg lag_attack clinton2 presey midey length scandal if (inrange(year, 1993,2000) & dem==1), robust
estimates store Attack
xi: nbreg lag_pub clinton2 presey midey length scandal if (inrange(year, 1993,2000) & dem==1), robust
estimates store Publicity
xi: nbreg lag_policy clinton2 presey midey length scandal if (inrange(year, 1993,2000) & dem==1), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure7_8_b, replace
gr combine Figure7_8_a.gph Figure7_8_b.gph, iscale(1)
graph save Figure7_8, replace
graph export Figure7_8.png, replace 

* Chapter 8: DNC and RNC, 2001-2016

* Update NYT Data for CH 8
use Data_1913_2016_3.dta
gen wbush1 = 0
replace wbush1=1 if (year==2000) & presey==0 & dem==0
replace wbush1=1 if (year==2001) & dem==0
replace wbush1=1 if (year==2002) & dem==0
replace wbush1=1 if (year==2003) & dem==0
replace wbush1=1 if (year==2004) & presey==1 & dem==0
gen obama1 = 0
replace obama1=1 if (year==2008) & presey==0 & dem==1
replace obama1=1 if (year==2009) & dem==1
replace obama1=1 if (year==2010) & dem==1
replace obama1=1 if (year==2011) & dem==1
replace obama1=1 if (year==2012) & presey==1 & dem==1
label variable wbush1 "G. W. Bush term 1"
label variable mcauliffe "McAuliffe"
label variable obama1 "Obama term 1"
label variable priebus "Priebus"
save Data_1913_2016_CH8.dta, replace

* Figure 8.1: Republican Electoral Performance, 2000-2016
use ElectoralPerformance.dta
line pvperc_r houseperc_r senateperc_r year if (inrange(year, 2000,2016)), yscale(range (0 100)) ylabel(0 (10) 100) xlabel(2000(4)2016) xtitle("") lpattern (solid dash) yline(50, lcolor(red)) legend( region(lcolor(white)))
graph save Figure8_1, replace
graph export Figure8_1.png, replace 

* Figure 8.2: George W. Bush presidency vs RNC under Clinton 2nd Term, 1997-2004
use Data_1913_2016_CH8.dta
xi: nbreg lag_brandingsum wbush1 presey midey length scandal  if (inrange(year, 1997,2004) & dem==0), robust
estimates store Branding
xi: nbreg lag_servicesum wbush1 presey midey length scandal  if (inrange(year, 1997,2004) & dem==0), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure8_2_a, replace
xi: nbreg lag_attack wbush1 presey midey length scandal  if (inrange(year, 1997,2004) & dem==0), robust
estimates store Attack
xi: nbreg lag_pub wbush1 presey midey length scandal  if (inrange(year, 1997,2004) & dem==0), robust
estimates store Publicity
xi: nbreg lag_policy wbush1 presey midey length scandal  if (inrange(year, 1997,2004) & dem==0), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure8_2_b, replace
gr combine Figure8_2_a.gph Figure8_2_b.gph, iscale(1)
graph save Figure8_2, replace
graph export Figure8_2.png, replace 

* Figure 8.3: McAuliffe vs. Second Clinton Term, 1997-2004
use Data_1913_2016_CH8.dta
xi: nbreg lag_brandingsum mcauliffe presey midey length scandal if (inrange(year, 1997,2004) & dem==1), robust
estimates store Branding
xi: nbreg lag_servicesum mcauliffe presey midey length scandal if (inrange(year, 1997,2004) & dem==1), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure8_3_a, replace
xi: nbreg lag_attack mcauliffe presey midey length scandal if (inrange(year, 1997,2004) & dem==1), robust
estimates store Attack
xi: nbreg lag_pub mcauliffe presey midey length scandal if (inrange(year, 1997,2004) & dem==1), robust
estimates store Publicity
xi: nbreg lag_policy mcauliffe presey midey length scandal if (inrange(year, 1997,2004) & dem==1), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure8_3_b, replace
gr combine Figure8_3_a.gph Figure8_3_b.gph, iscale(1)
graph save Figure8_3, replace
graph export Figure8_3.png, replace 

* Figure 8.4: Democratic Electoral Performance, 2000-2016
use ElectoralPerformance.dta
line pvperc_d houseperc_d senateperc_d year if (inrange(year, 2000,2016)), yscale(range (0 100)) ylabel(0 (10) 100) xlabel(2000(4)2016) xtitle("") lpattern (solid dash shortdash) yline(50, lcolor(red)) legend( region(lcolor(white)))
graph save Figure8_4, replace
graph export Figure8_4.png, replace 

* Figure 8.5: Obama First Term vs. Dean, 2005-2012
use Data_1913_2016_CH8.dta
xi: nbreg lag_brandingsum obama1 presey midey length scandal if (inrange(year, 2005,2012) & dem==1), robust
estimates store Branding
xi: nbreg lag_servicesum obama1 presey midey length scandal if (inrange(year, 2005,2012) & dem==1), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure8_5_a, replace
xi: nbreg lag_attack obama1 presey midey length scandal if (inrange(year, 2005,2012) & dem==1), robust
estimates store Attack
xi: nbreg lag_pub obama1 presey midey length scandal if (inrange(year, 2005,2012) & dem==1), robust
estimates store Publicity
xi: nbreg lag_policy obama1 presey midey length scandal if (inrange(year, 2005,2012) & dem==1), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure8_5_b, replace
gr combine Figure8_5_a.gph Figure8_5_b.gph, iscale(1)
graph save Figure8_5, replace
graph export Figure8_5.png, replace 

* Figure 8.6: Priebus vs. Steele, 2009-2016
use Data_1913_2016_CH8.dta
xi: nbreg lag_brandingsum priebus presey midey length scandal  if (inrange(year, 2009,2016) & dem==0), robust
estimates store Branding
xi: nbreg lag_servicesum priebus presey midey length scandal  if (inrange(year, 2009,2016) & dem==0), robust
estimates store Service
coefplot Branding Service, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure8_6_a, replace
xi: nbreg lag_attack priebus presey midey length scandal if (inrange(year, 2009,2016) & dem==0), robust
estimates store Attack
xi: nbreg lag_pub priebus presey midey length scandal if (inrange(year, 2009,2016) & dem==0), robust
estimates store Publicity
xi: nbreg lag_policy priebus presey midey length scandal if (inrange(year, 2009,2016) & dem==0), robust
estimates store Policy
coefplot Attack Publicity Policy, drop(presey midey length scandal _cons) xline(0) xscale(range(-3 3)) xlabel(-3[1]3) legend( region(lcolor(white)))
graph save Figure8_6_b, replace
gr combine Figure8_6_a.gph Figure8_6_b.gph, iscale(1)
graph save Figure8_6, replace
graph export Figure8_6.png, replace 
